请问哪里出错了呢??循环队列
#include "stdio.h"#include "malloc.h"
#define QueueSize 20
/*#define ERROR 0
#define OK 1*/
#define MAXQSIZE 100
typedef int QElemType;
typedef struct
{
QElemType *base;
int front;
int rear;
}SqQueue;
SqQueue * InitQueue ()
{
SqQueue *Q;
Q=(SqQueue*)malloc(MAXQSIZE*sizeof(SqQueue));
Q->front=Q->rear=0;
return Q;
}
void EnQueue(SqQueue *Q,QElemType e){
if((Q->rear+1)%MAXQSIZE==Q->front) printf("溢出");;
Q->base[Q->rear]=e;
Q->rear=(Q->rear+1)%MAXQSIZE;
}
QElemType DeQueue (SqQueue *Q){
QElemType e;
if(Q->front==Q->rear) printf("队列为空");
e=Q->base[Q->front];
Q->front=(Q->front+1)%MAXQSIZE;
return e;
}
QElemType GetHead(SqQueue *Q){
QElemType e;
if(Q->front==Q->rear) return 0;
else
e=Q->base[Q->front];
return e;}
int QueueEmpty(SqQueue *Q){
return (Q->front==Q->rear);}
void TraverSq(SqQueue Q){
do{
printf("%d\t",DeQueue(&Q));
}while(!QueueEmpty(&Q));
}
void YangHui(int n){
SqQueue *q;
int j,s,t;
q=InitQueue();
EnQueue(q,0);
EnQueue(q,1);
for(j=1;j<=n;j++)
{
EnQueue(q,0);
do{
s=DeQueue(q);
t=GetHead(q);
if(t)
printf("%d\t",t);
else
printf("\n");
EnQueue(q,s+t);
}while(t!=0);
}
DeQueue(q);
TraverSq(*q);
}
void main(){
YangHui(5);
}