主题:这是个队列的源代码,错在那里??
#include<stdio.h>
#include<stdlib.h>
#define MAXQSIZE 100;
typedef char QElemType;
typedef int Statue;
typedef struct SqQueue{
QElemType *base;
int front;
int rear;
}SqQueue;
Status InitQueue(SqQueue *Q){
Q->base=(QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
if(!Q->base)
exit(-1);
Q->front=Q->rear=0;
return 1;
}
int Queuelength(SqQueue *Q){
return (Q->rear-Q->front+MAXQSIZE)%MAXQSIZE;
}
Statue EnQueue(SqQueue *Q,QElenType *e)
{
if((Q->tear+1)%MAXQSIZE==Q->front){
printf("man");
exit(-1);
}
Q->base[Q->rear]=*e;
Q->rear=(Q->rear+1)%MAXQSIZE;
return 1;
}
void Dequeue(SqQueue *Q,QElemType *e){
if(Q->rear==Q->front){
printf("kongzhan");
exit(-1);
}
*e=Q->base[Q->front];
Q->front=(Q->front+1)%MAXQSIZE;
}
Statue main()
{
SqQueue S;
QElemType a;
InitQueue(&S);
scanf("%c",&a);
while(a!='\n'){
printf("shuru yuansu");
scanf("%c",&a);
EnQueue(&S,&a);
}
DeQueue(&S,&a);
printf("shanchude yuansushi %c",a);
return 1;
}
#include<stdlib.h>
#define MAXQSIZE 100;
typedef char QElemType;
typedef int Statue;
typedef struct SqQueue{
QElemType *base;
int front;
int rear;
}SqQueue;
Status InitQueue(SqQueue *Q){
Q->base=(QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
if(!Q->base)
exit(-1);
Q->front=Q->rear=0;
return 1;
}
int Queuelength(SqQueue *Q){
return (Q->rear-Q->front+MAXQSIZE)%MAXQSIZE;
}
Statue EnQueue(SqQueue *Q,QElenType *e)
{
if((Q->tear+1)%MAXQSIZE==Q->front){
printf("man");
exit(-1);
}
Q->base[Q->rear]=*e;
Q->rear=(Q->rear+1)%MAXQSIZE;
return 1;
}
void Dequeue(SqQueue *Q,QElemType *e){
if(Q->rear==Q->front){
printf("kongzhan");
exit(-1);
}
*e=Q->base[Q->front];
Q->front=(Q->front+1)%MAXQSIZE;
}
Statue main()
{
SqQueue S;
QElemType a;
InitQueue(&S);
scanf("%c",&a);
while(a!='\n'){
printf("shuru yuansu");
scanf("%c",&a);
EnQueue(&S,&a);
}
DeQueue(&S,&a);
printf("shanchude yuansushi %c",a);
return 1;
}