解题思路: 再开辟另一个结点并使p1指向它,接着输入该结点的数据 head p1 p2 10101 89.5 10103 90 10107 85 0 … p1=(struct Student*)malloc(LEN); scanf(%ld,%f,p1-num,p1-score); 解题思路: 输入的学号为0,表示建立链表的过程完成,该结点不应连接到链表中 head p1 p2 10101 89.5 10103 90 10107 85 0 … NULL p2-next=NULL; #include stdio.h #include stdlib.h #define LEN sizeof(struct Student) struct Student { long num; float score; struct Student *next; }; int n; struct Student类型数据的长度 struct Student *creat(void) { struct Student *head,*p1,*p2; n=0; p1=p2=( struct Student*) malloc(LEN); scanf(“%ld,%f”,p1-num,p1-score); head=NULL; while(p1-num!=0) {n=n+
原创力文档

文档评论(0)