1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
struct stu{
int num,score;
stu* next;
};
int main(){
stu* head = NULL,* p1,* p2;
p1 = (stu*)malloc(sizeof(stu));
p1 ->next = NULL;
scanf("%d%d",&p1->num,&p1->score);
while(p1 -> num != 0){
if(head != NULL){
p2->next = p1;
}else{
head = p1;
}
p2 = p1;
p1 = (stu*)malloc(sizeof(stu));
scanf("%d%d",&p1->num,&p1->score);
p1 ->next = NULL;
}
stu *p = head;
while(p != NULL){
printf("%d %d\n",p->num,p->score);
p = p ->next;
}
return 0;
}
|