#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int num;
struct node *next
}que;
typedef struct
{
que *front;
que *rear;
}link;
int main()
{
link *q;
q->front=(que *)malloc(sizeof(que));
if(q->front!=NULL)
{
q->rear=q->front;
q->front->next=NULL;
}
que *p;
int x;
printf("输入队列数据");
while(scanf("%d",&x),x!=0)
{
p=(que *)malloc(sizeof(que));
p->num=x;
q->rear->next=p;
q->rear=p;
}
while(q->front!=q->rear)
{
printf("%d",q->front->num);
q->front=q->front->next;
}
return 0;
}
#include <stdlib.h>
typedef struct node
{
int num;
struct node *next
}que;
typedef struct
{
que *front;
que *rear;
}link;
int main()
{
link *q;
q->front=(que *)malloc(sizeof(que));
if(q->front!=NULL)
{
q->rear=q->front;
q->front->next=NULL;
}
que *p;
int x;
printf("输入队列数据");
while(scanf("%d",&x),x!=0)
{
p=(que *)malloc(sizeof(que));
p->num=x;
q->rear->next=p;
q->rear=p;
}
while(q->front!=q->rear)
{
printf("%d",q->front->num);
q->front=q->front->next;
}
return 0;
}