PAT_乙_1004成绩排名
程序员文章站
2024-03-08 08:43:57
...
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
struct Student{
char name[15];
char sno[15];
int score;
}temp_stu ,max_score_stu,min_score_stu;
int main()
{
int n;
while(cin>>n)
{
max_score_stu.score = -1;
min_score_stu.score = 101;
for(int i=0;i<n;i++){
//cin>>temp_stu.name>>temp_stu.sno>>temp_stu.score;
scanf("%s %s %d",temp_stu.name, temp_stu.sno, &temp_stu.score);
if(temp_stu.score>max_score_stu.score){
max_score_stu = temp_stu;
}
if(temp_stu.score<min_score_stu.score){
min_score_stu = temp_stu;
}
}
cout<<max_score_stu.name<<" "<<max_score_stu.sno<<endl;
cout<<min_score_stu.name<<" "<<min_score_stu.sno<<endl;
}
}