- #include <stdio.h>
- #include <stdlib.h>
- int queue[10];
- int front=-1;
- int rear=-1;
- void addqueue(int number)
- {
- if(rear-front>=10)
- {
- printf("the queue is full");
- }else{
- rear++;
- queue[rear]=number;
- }
- }
- int delqueue()
- {
- int temp;
- if(front==rear)
- {
- printf("the queue is empty");
- return -1;
- }else{
- front++;
- temp=queue[front];
- queue[front]=0;
- return temp;
- }
- }
- int main()
- {
- int select;
- printf("(1)input a data");
- printf("(2)output a data");
- printf("(3)exit");
- scanf("%d",&select)
- while(select!=3)
- {
- int number;
- switch(select)
- {
- case 1:scanf("%d",&number);addqueue(number);break;
- case 2:delqueue();break;
- }
- printf("(1)input a data");
- printf("(2)output a data");
- printf("(3)exit");
- scanf("%d",&select)
- }
- return 0;
- }