C语言帮我加上注释好吗

#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
float score;
struct student * next;
};
int n;
struct student * creat(void)
{
struct student * head;
struct student * 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+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student * )malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}

#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student) //LEN为student结构大小
struct student
{
long num;
float score;
struct student * next;
};
int n;
struct student * creat(void)
{
struct student * head;
struct student * p1, * p2;
n=0;
p1=p2=( struct student * ) malloc(LEN);//分配一个student空间,p1,p2指向它
scanf("%ld,%f",&p1->num,&p1->score);//输入num,score的值
head=NULL;
while(p1->num!=0) //num不为0时循环
{
n=n+1;
if(n==1)head=p1; //第一次循环设定head指向p1
else p2->next=p1; //后续循环p2的next为p1
p2=p1; //p2后移,就是p2一直都是指向最后的元素,在p2后面添加
p1=(struct student * )malloc(LEN); //添加下一个元素
scanf("%ld,%f",&p1->num,&p1->score); //输入num,score
}
p2->next=NULL; //最后一个元素的next为空
return(head);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-08-13
这个是链表的程序么 书上应该有解析的才对吧~
如果你不嫌麻烦的话 给你看个视频教程吧~
http://www.bilibili.com/video/av418203/
讲的还不错的~