关于队列链式的问题
#include <stdio.h>#include <malloc.h>
#define MAXSIZE 100
#define ERROR -1
#define true 0
typedef char ElementType;
typedef struct LNode {
ElementType a;
struct LNode *next;
}*List;
typedef struct Link
{
List front,rear;
}*QNde;
MakeEmpty(QNde *s)
{
(*s)->front=(*s)->rear=(List)malloc(sizeof(struct LNode));
(*s)->front=(*s)->rear;
(*s)->front->next=NULL;
}
void enter(QNde *s,ElementType x)
{
List t;
t=(List)malloc(sizeof(struct LNode));
t->a=x;
t->next=NULL;
if((*s)->front->next==NULL)
{
(*s)->front->next=t;
(*s)->rear->next=t;
}
else
{
t=(*s)->rear->next->next;
(*s)->rear->next=t;
}
}
void delete(QNde *s)
{
List q;
if((*s)->front->next==NULL)
printf("队空");
else
{
if((*s)->front->next==(*s)->rear->next)
{
q=(*s)->front->next;
(*s)->front->next=NULL;
(*s)->rear->next=NULL;
}
else
{
q=(*s)->front->next;
(*s)->front->next=q->next;
}
free(q);
}
}
void display(QNde *s)
{
List q;
q=(*s)->front->next;
printf("队的显示:\n");
if((*s)->front->next==NULL)
printf("空队");
else
{
if((*s)->front->next==(*s)->rear->next)
{
printf("%c",q->a);
}
else
{
while(q->next!=NULL)
{
printf("%c",q->a);
q=q->next;
}
printf("%c",q->a);
}
}
printf("\n");
}
main()
{
QNde *qu;
printf("初始化队列 qu\n");
MakeEmpty(qu);
printf("依次入队 a,b,c,d 元素\n");
enter(qu,'a');
enter(qu,'b');
enter(qu,'c');
enter(qu,'d');
display(qu);
printf("出队一次\n");
delete(qu);
display(qu);
printf("出队一次\n");
delete(qu);
display(qu);
}
问下哪错了,运行不出来,谢谢....