1004 成绩排名 (20分)
直接sort了,找最大最小值
#include<iostream>
#include<algorithm>
using namespace std;
struct Node{
string name;
string id;
int grade;
};
bool cmp(Node a,Node b){
return a.grade>b.grade;
}
int main(){
int n;cin>>n;
struct Node node[n];
for(int i=0;i<n;i++){
cin>>node[i].name>>node[i].id>>node[i].grade;
}
sort(node,node+n,cmp);
cout<<node[0].name<<" "<<node[0].id<<"
";
cout<<node[n-1].name<<" "<<node[n-1].id<<"
";
return 0;
}