关于创建动态链表的一块不理解的地方
程序如下:# include <stdio.h>
# include <stdlib.h>
struct Stu
{
int num;
double score;
Stu * next;
};
int n=0;
Stu * creat(void)
{
Stu * head, * p, * q;
p=q=(Stu *)malloc(sizeof(Stu));
scanf("%d,%lf", &p->num, &p->score);
head=NULL;
while (p->num!=0)
{
n+=1;
if (n==1)
head=p;
else
q->next=p;//改行和下一行表示什么意思呢?求教。
q=p;
p=(Stu *)malloc(sizeof(Stu));
scanf("%d,%lf", &p->num, &p->score);
}
q->next=NULL;
return head;
}
int main(void)
{
struct Stu * pt;
pt=creat();
printf("\nnum:%d\nscore:%5.1lf\n", pt->num, pt->score);
return 0;
}
-----------------------------