队列
队满条件:(Q.rear+1)%maxsize==Q.front
队空条件:Q.front==Q.rear
队中元素个数:(Q.rear-Q.front+maxsize)%maxsize
//判队空
int isEmpty(SqQueue Q)
{
if(Q.rear==Q.front) return 1;
else
return 0;
}
//入队
int EnQueue(SqQeue &Q,ElemType x)
{
if((Q.rear+1)%maxsize==Q.front)
return 0;
Q.data[rear]=x;
Q.rear=(Q.rear+1)%maxsize;
return 1;
}
//出队
int DeQueue(SqQueue &Q,ElemType &e)
{
if(Q.front==Q.rear) return 0;
e=Q.data[front];
Q.front=(Q.front+1)%maxsize;
return 1;
}