下面是我写的代码,能运行但是你输入几个A就出来几个ERROR FULL
只有这个结果我也不知道为什么,求大神解答
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
int top;
}*Qnode;
Qnode CreateList()
{
Qnode L;
L=(Qnode)malloc(sizeof(struct Node));
L->next=NULL;
L->top=0;
return L;
}
Qnode InsertList(Qnode L,int e,int n)
{
if(L->top=n)
{
printf("ERROR FULL");
}
else
{
Qnode p;
p=(Qnode)malloc(sizeof(struct Node));
p->next=L->next;
L->next=p;
p->data=e;
L->top++;
}
return L;
}
Qnode PopList(Qnode L)
{
if(L->top=0)
{
printf("ERROR EMPTY");
}
else
{
Qnode q;
q=(Qnode)malloc(sizeof(struct Node));
q=L->next;
printf("%d\n",q->data);
L->next=q->next;
L->top--;
}
return L;
}
int main()
{
Qnode L;
L=CreateList();
char m;
int n,e;
scanf("%d",&n);
scanf("%c",&m);
if(m=='T')
{
exit(0);
}
while(m!='T')
{
if(m=='A')
{
scanf("%d",&e);
InsertList(L,e,n);
}
else if(m=='D')
{
PopList(L);
}
scanf("%c",&m);
}
return 0;
}