有人帮我看下我这个队列为什么不能出队不?
程序代码:#include<stdio.h>
#include<stdlib.h>
struct node {
int data;
struct node *next;
};
int main() {
int k;
struct node *front,*rear;
struct node *p=(struct node *)malloc(sizeof(struct node));
p->next=0;
front=rear=p;
for(int i=0; i<3; i++) {
p->next=(struct node *)malloc(sizeof(struct node));
scanf("%d",&k);
p->data=k;
p->next=0;
rear->next=p;
rear=p;
}
for(p=front; front!=rear;) {
printf("%d",p->data);
front->next=p->next;
if(p->next==0)rear=front;
free(p);
}
return 0;
}









~
