学生信息输入输出
#include<stdio.h>
#include<stdlib.h>
struct student
{
int data;
char name[20];
int score;
struct student *next;
};
typedef struct student *stu;
int main()
{
struct student *head,*tail,*p;
head=(stu)malloc(sizeof(struct student));
head->next=NULL;
tail=head;
int x;
scanf("%d",&x);
while(x!=0)
{
p=(stu)malloc(sizeof(struct student));
p->next = NULL;
p->data = x;
scanf("%s%d",p->name,&p->score);
tail->next = p;
tail = p;
scanf("%d",&x);
}
for(p = head->next; p != NULL; p = p->next){
printf("%d %s %d\n",p->data,p->name,p->score);
}
return 0;
}