关于针对对列中Front后直接是rear但却只有一个元素问题
#include<stdio.h>
#include<stdlib.h>
typedef int ElementType;
typedef int P;
typedef struct QNode* List;
struct QNode{
P data;
P front,rear;
int max;
};
List Creatlist(int max)//创建空栈
{
List Q;
Q=(List)malloc(sizeof(struct QNode));
Q->data=(P)malloc(sizeof§);
Q->max=max;
Q->front=Q->rear=0;
return Q;
}
bool isFull(List S)//判断是否栈满
{
return ((S->rear+1)%S->maxS->front);
}
bool Addlist(List S,ElementType X)//进栈
{
if(isFull(S))
{
printf(“队列满\n”);
return 0;
}
else
{
S->rear=(S->rear+1)%S->max;
S->data[S->rear]=X;
return 1;
}
}
bool isEmpty(List Q)
{
return (Q->frontQ->rear);
}
ElementType DeletS(List S)
{
if(isEmpty(S))
{
printf(“链表为空\n”);
return 0;
}
else
{
S->front=(S->front+1)%S->max;
return S->data[S->front];
}
}