循环队列的C实现
											有没有循环队列的C实现啊,急用!!!!!!!!!!!!!!!!!!!1										
					
	
				
											#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef int QElemType;
#define MAXQSIZE 100
typedef struct
{
    QElemType *base;
    int front;
    int rear;
}SqQueue;
void InitQueue(SqQueue &Q)
{
    Q.base=(QElemType *)malloc(MAXQSIZE *sizeof(QElemType));
    if(!Q.base)
        exit(1);
    Q.front=Q.rear=0;
}
int QueueLength(SqQueue &Q)
{
    return (Q.rear-Q.front+MAXQSIZE)%MAXQSIZE;
}
void EnQueue(SqQueue &Q,QElemType e)
{
    if((Q.rear+1)%MAXQSIZE == Q.front)
        exit(1);
    Q.base[Q.rear]=e;
    Q.rear=(Q.rear+1)%MAXQSIZE;
}
void DeQueue(SqQueue &Q,QElemType &e)
{
    if(Q.front == Q.rear)
        exit(1);
    e=Q.base[Q.front];
    Q.front=(Q.front+1)%MAXQSIZE;
}
int main()
{
    const int n=5;
    int a[n],
        i,
        e=0;
    SqQueue Q;
    InitQueue(Q);
    for(i=0;i<n && scanf("%d",&a[i]);i++);
    for(i=0;i<n;i++)
    {
        EnQueue(Q,a[i]);
    }
//    DisplayQueue(Q);
    printf("\n 出队列的元素为:\n ");
    for(i=0;i<n;i++)
    {
        DeQueue(Q,e);
    //    printf("\n 出队列的元素为:\n ");
        printf("\n%d\n",e);
    }
    return 0;
}										
					
	
	
	
			


											
	    

	
