#include<stdio.h>
#define ElemType int
#include<malloc.h>
#define MAXSIZE 10
typedef struct{
ElemType *data;
int front,rear;
}Queue;
typedef struct BitNode{
ElemType data;
struct Bitree *Lchild,*Rchild;
}BitNode;
Queue Init_queue(Queue Q){
Q.data=(ElemType *)malloc(MAXSIZE*sizeof(ElemType));
Q.front=Q.rear=0;
return Q;
}
Queue Enter_queue(Queue Q,ElemType e){
if((Q.rear+1)%MAXSIZE==Q.front){
printf("队满");
}else{
*(Q.data+Q.rear)=e;
Q.rear=(Q.rear+1)%MAXSIZE;
}
return Q;
}
Queue Leave_queue(Queue Q){
ElemType e;
if(Q.rear==Q.front){
printf("队空");
}else{
printf("eo");
e=*(Q.data+Q.front);
printf("%d出队
",e);
Q.front=(Q.front+1)%MAXSIZE;
}
return Q;
}
int main(){
Queue Q;
int e,a;
Q=Init_queue(Q);
printf("请输入入队的数:
");
scanf("%d",&e);
while(e!=-1){
Q=Enter_queue(Q,e);
scanf("%d",&e);
}
while(*(Q.data+Q.front)){
Q=Leave_queue(Q);
}
return 0;
}