为什么没有输出啊....
#include "stdio.h"
#include "stdlib.h"
#define S struct Worker
S
{
int num;
char name[20];
char sex;
int pay;
S *prec;
S *next;
};
void main()
{
S *p1,*p2,*head;
p1=p2=head=(S*)malloc(sizeof(S));
scanf("%d",&p1->num);
getchar();
scanf("%s",p1->name);
getchar();
scanf("%c",&p1->sex);
getchar();
scanf("%d",&p1->pay);
getchar();
head->prec=0;
p1->next=0;
while(1)
{
(S*)malloc(sizeof(S));
scanf("%d",&p1->num);
if(p1->num==0) break;
getchar();
scanf("%s",p1->name);
getchar();
scanf("%c",&p1->sex);
getchar();
scanf("%d",&p1->pay);
getchar();
p1->prec=p2;
p2->next=p1;
p1->next=0;
p2=p1;
}
p1=p2;
p2->next=0;
while(p2->num!=0)
{
printf("%d %s %c %d\n",p2->num,p2->name,p2->sex,p2->pay);
p2=p2->prec;
}
p1=head;
while(p1->num!=0)
{
printf("%d %s %c %d\n",p1->num,p1->name,p1->sex,p1->pay);
p1=p1->next;
}
}
----------------解决方案--------------------------------------------------------
你的HEAD的NUM值是多少
[此贴子已经被作者于2007-4-2 15:59:16编辑过]
----------------解决方案--------------------------------------------------------
.......照着例子多看下吧,,,,
----------------解决方案--------------------------------------------------------