#include<stdio.h>
#include<stdlib.h>
typedef struct Stu{
char name[100];
int score;
struct Stu* next;
};
Stu* creat(int n){
int i;
Stu* p,* head;
head=p=(Stu*)malloc(sizeof(Stu));
for(i=0;i<n;++i){
scanf("%s %d",p->name,&p->score);
p->next=(Stu*)malloc(sizeof(Stu));
p=p->next;
}
return head;
}
void pwd(Stu* head,int n){
int i;
for(i=0;i<n;++i){
printf("%s %d",head->name,head->score);
head=head->next;
}
}
int main(){
Stu* head;
int n;
scanf("%d",&n);
head=creat(n);
pwd(head,n);
}
21天作业1
最新推荐文章于 2024-06-09 19:21:43 发布