include
#include
struct student
{
int num;
char name[20];
int score;
struct student * next;
};
int main(void)
{
struct student * p[4];
int i;
//构建链表
p[0] = (struct student *)malloc(sizeof(struct student));
scanf("%d%s%d", &p[0]->num, p[0]->name, &p[0]->score);
for(i = 1; i < 4; ++i){
p[i] = (struct student *)malloc(sizeof(struct student));
scanf("%d%s%d", &p[i]->num, p[i]->name, &p[i]->score);
p[i - 1]->next = p[i];
}
p[i]->next = NULL;
//输出链表
printf("NO.%d name:%s score: %d\n", p[0]->num, p[0]->name, p[0]->score);
for(i = 1; i < 4; ++i){
p[i] = p[i - 1]->next;
printf("NO.%d name: %s score: %d\n", p[i]->num, p[i]->name, p[i]->score);
}
return 0;
}
p[i]->next = NULL; 去掉就okay~