各位麻烦看看下面的程序,是利用链表输入输出成绩,但是在输入时出现了问题,请帮忙解决 #include <malloc.h> #define NULL 0 #define LEN sizeof(struct student) struct student { int num; int score ; struct student *next;
}; struct student creat (struct student *p) { struct student *p1;
p1=p; printf("please input the number\n"); scanf("%d %d\n",&p->num,&p->score);
if( (p->num)==0) {p->next=NULL; return; } else {p1=(struct student *)malloc(LEN); p->next=p1; creat(p1); } } void print(struct student *p) { if (p->num !=0) printf("num=%d,score=%d\n",p->num,p->score); if (p->next!=NULL) print(p->next); return; }
main() { struct student a; struct student *head;
head=&a; clrscr(); creat(head); printf("the record you input justnow is\n"); print(head); }
----------------解决方案--------------------------------------------------------
什么样的问题
----------------解决方案--------------------------------------------------------