#include int *base; int rear; int front; }queue; void init(queue *q) { q->base=(int *)malloc(LENGTH*sizeof(int)); if(!(q->base))return; q->rear=0; q->front=0; } int full(queue *q) { if((q->rear+1)%LENGTH==q->front)return 1; else return 0; } int empty(queue *q) { if(q->rear==q->front)return 1; else return 0; } void enQueue(queue *q,int e) { if(full(q)){printf(\"full\\n\");return;} q->base[q->rear]=e; q->rear=(q->rear+1)%LENGTH; } void deQueue(queue *q,int *e) { if(empty(q)){printf(\"empty\");return;} *e=q->base[q->front]; q->front=(q->front+1)%LENGTH; } main() { int array[]={1,2,3,4,5,6,7,8,9,12,23,34,56,67}; int i=0; queue *q; q=(queue *)malloc(sizeof(queue)); init(q); while(full(q)!=1) { enQueue(q,array[i++]); } while(empty(q)!=1) { deQueue(q,&i); printf(\"%d \ } getch(); } 因篇幅问题不能全部显示,请点此查看更多更全内容