#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
}NodeQueue;
typedef struct Link
{
NodeQueue *front;
NodeQueue *rear;
}LinkQueue;
int CreatLinkQueue(LinkQueue *Q)
{
Q=(LinkQueue*)malloc(sizeof(LinkQueue));
Q->front=(NodeQueue*)malloc(sizeof(NodeQueue));
if(Q!=NULL)
{
Q->rear=Q->front;
Q->front->next=NULL;
return 1;
}
else
return 0;
}
void EnterQueue(LinkQueue *Q)
{
int c,flag;
NodeQueue *node;
printf("进队\n");
while(flag)
{
scanf("%d",&c);
if(c!=0)
{
node=(NodeQueue*)malloc(sizeof(NodeQueue));
node->data=c;
node->next=NULL;
Q->rear->next=node;
Q->rear=node;
flag=1;
}
else
flag=0;
}
}
int DeleteQueue(LinkQueue *Q)
{
LinkQueue *q;
if(Q->front==Q->rear)
return 0;
q=Q;
while(q->front->next!=NULL)
{
q->front=q->front->next;
printf("\n%d",q->front->data);
}
return 1;
}
void main()
{
LinkQueue *Q;
Q=(LinkQueue*)malloc(sizeof(LinkQueue));
CreatLinkQueue(Q);
EnterQueue(Q);
DeleteQueue(Q);
}
输入数据进不去,请帮忙看看,谢谢...运行环境vc++6.0
[此贴子已经被作者于2007-1-3 1:13:56编辑过]