PAT (Basic Level) Practice 1004 成绩排名 (C语言)
作者:互联网
#include<stdio.h>
#include<string.h>
int main(){
int max=0,min=100;
char maxname[11], maxid[11], minname[11], minid[11];
char name[11],id[11];
int score=0;
int n,count=1;
scanf("%d",&n);
while(count<=n){
scanf("%s",&name);
scanf("%s",&id);
scanf("%d",&score);
if(score<min){
min=score;
strcpy(minname,name);
strcpy(minid,id);
}if(score>max){
max=score;
strcpy(maxname,name);
strcpy(maxid,id);;
}count++;
}
printf("%s %s\n",maxname,maxid);
printf("%s %s",minname,minid);
return 0;
}
用了一个strcpy,就没把所有人的数据都储存起来了,比一个扔一个~
标签:11,成绩排名,PAT,name,Level,int,score,strcpy,id 来源: https://blog.csdn.net/weixin_54237224/article/details/118874382