#include"stdafx.h"
#include
#define LEN sizeof(student)
struct student{
int num;
float score;
student *next;
};
student * creat(){
int num;
float score;
student *head, *p,*q;
q=p=head = (student *)malloc(LEN);
head->num = NULL;
scanf_s("%d%f",&num,&score);
while (num != 0)//如果输入0的话就当成结束
{
p = (student*)malloc(LEN);
p->num = num;
p->score = score;
p->next = NULL;
q->next = p;
q = p;
scanf_s("%d%f",&num,&score);
}
p->next = NULL;
return head;
}
void print(student * head){
student *p;
p = head;
for (; p->next != NULL;)
{
printf("%d %f", p->next->num, p->next->score);
p = p->next;
}
}
void main(){
student *head;
creat();
head = creat();
print(head);
}
//我输入
1 20
2 30
3 40
0 10
的话没有输出什么东西啊