#include <stdio.h>
#include <malloc.h>
typedef struct Student
{
long id;
double score;
struct Student * next;
} STU; //STU等价于struct Student
int main(void)
{
STU * head, * tail, * new;
head = (STU *)malloc(sizeof(STU));
tail = head;
tail->next = NULL;
while(1)
{
new = (STU *)malloc(sizeof(STU));
printf("请输入学生学号(学号为0结束):");
scanf("%ld", &new->id);
if(new->id == 0)
{
break;
}
printf("请输入学生成绩:");
scanf("%lf", &new->score);
tail->next = new;
new->next = NULL;
tail = new;
}
STU * p = head->next;
while(p)
{
printf("学号为%ld学生的成绩是:%.2lf\n", p->id, p->score);
p = p->next;
}
return 0;
}