主题:帮帮看看哪里错了
#define MAXSIZE 50
#define NULL 0
typedef struct
{ long num;
char name[20];
int age;
char sex;
char address[20];
}student;
typedef struct Node
{ student data;
struct Node *next;
} LNode,*LinkList;
LinkList Creat_LinkList()
{
LinkList L;
LNode *s;
int x;
int flag = -1;
L = (LNode *) malloc (sizeof(LNode));
L -> next = NULL;
printf("请输入节点值,如链表结束,请输入-1:");
scanf("%ld%s%c%d%s",&student.num,&x->student.name,&x->student.age,&x->student.sex,&x->student.address);
while(x!= flag )
{
s = (LNode *) malloc (sizeof(LNode));
s ->data=x;
s ->next=L->next;
L ->next=s ;
printf("请输入节点值,如链表结束,请输入-1:");
scanf("%d",&x);
}
return L;
}
int void Show_LinkList(LinkList L)
{
LNode *s;
s = L;
while(s->next != NULL)
{
s = s -> next ;
printf(" %d ",s->data);
}
printf("\n");
}
main()
{ int i,j,x;
LinkList L;
do{
printf("1、从前面插入的链表 2、输出 0、退出\n");
scanf("%d",&i);
if(i == 1 ) L = Creat_LinkList();
if(i == 2 ) Show_LinkList( L);
}while(i!=0);
return 0;
}
#define NULL 0
typedef struct
{ long num;
char name[20];
int age;
char sex;
char address[20];
}student;
typedef struct Node
{ student data;
struct Node *next;
} LNode,*LinkList;
LinkList Creat_LinkList()
{
LinkList L;
LNode *s;
int x;
int flag = -1;
L = (LNode *) malloc (sizeof(LNode));
L -> next = NULL;
printf("请输入节点值,如链表结束,请输入-1:");
scanf("%ld%s%c%d%s",&student.num,&x->student.name,&x->student.age,&x->student.sex,&x->student.address);
while(x!= flag )
{
s = (LNode *) malloc (sizeof(LNode));
s ->data=x;
s ->next=L->next;
L ->next=s ;
printf("请输入节点值,如链表结束,请输入-1:");
scanf("%d",&x);
}
return L;
}
int void Show_LinkList(LinkList L)
{
LNode *s;
s = L;
while(s->next != NULL)
{
s = s -> next ;
printf(" %d ",s->data);
}
printf("\n");
}
main()
{ int i,j,x;
LinkList L;
do{
printf("1、从前面插入的链表 2、输出 0、退出\n");
scanf("%d",&i);
if(i == 1 ) L = Creat_LinkList();
if(i == 2 ) Show_LinkList( L);
}while(i!=0);
return 0;
}