#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(struct Student)
struct Student
{
int num;
float score;
struct Student *next;
}man;
struct Student *creat(void)
{
struct Student *p1,*p2,head;
int n=0,i=0;
head=NULL;
p1=p2=(struct Student)malloc(100);
printf("请输入学号:");
scanf("%d",&p1->num);
printf("请输入成绩:");
scanf("%f",&p1->score);
while(p1->num!=0)
{
n=n+1;
if(n==1)
{
head=p1;
}
else
{
p2->next=p1;
}
p2=p1;
p1=(struct Student*)malloc(LEN);
printf("请输入学号:");
scanf("%d",&p1->num);
printf("请输入成绩:");
scanf("%f",&p1->score);
}
p2->next=NULL;
return (head);
}
void main()
{
#if(0)
int i=0;
struct Student *head;
head=creat();
if(head!=NULL)
do
{
printf("the %d 同学的成绩: %f \n",head->num,head->score);
head=head->next;
}while(head=NULL);
#endif
struct Student *creat(void);
do
{
printf("the %d 同学的成绩: %f \n",creat()->num,creat()->score);
creat()=creat()->next;
}while(creat()!=NULL);
}