1:
头文件:
#include
#include
#include
2:
搭建链表:
struct student *creat()
{
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student *)malloc(LEN);
printf("please enter the num :");
scanf("%d",&p1->num);
printf("please enter the score :");
scanf("%f",&p1->score);
head=NULL;
while(0 != p1->num)
{
n++;
if(n==1)
{
head=p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct student *)malloc(LEN);
printf("nplease enter the num :");
scanf("%d",&p1->num);
printf("please enter the score :");
scanf("%f",&p1->score);
}
p2->next=NULL;
return (head);
}
3:
输出链表:
int print(struct student *head)
{
struct student *p;
printf("nthere are %d records!nn",n);
p=head;
if(head!=NULL)
{
do
{
printf("学号为:%d 的成绩是:%fn",p->num,p->score);
p=p->next;
}while(p);
}
}



