#include
#include
#define LEN sizeof(struct Student)
struct Student //声明结构体
{int num;
int score;
struct Student *next;
};
int n;//全局变量
struct Student *creat(void);//声明函数
void print(struct Student *head);//声明函数
struct Student *creat(void) //定义函数
{struct Student *head;
struct Student *p1,*p2;
p1=p2=(struct Student *)malloc(LEN);
n=0;
head=NULL;
scanf("%d,%d",&p1->num,&p1->score);
fflush(stdin);
while(p1->num!=0)
{ n++;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct Student *)malloc(LEN);
scanf("%d,%d",&p1->num,&p1->score);
fflush(stdin);
}
p2->next=NULL;
return(head);
}
void print(struct Student *head) //定义输出函数
{struct Student *p;
printf("\nNow,These %d records are:\n",n);
p=head;
if(head!=NULL)
do
{printf("%d %d\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
}
int main()//主函数
{struct Student *pt;
pt=creat();
print(pt);
return 0;
}