pat B1004
题目链接如下
https://pintia.cn/problem-sets/994805260223102976/problems/994805321640296448
代码如下
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct Student {
string name1,name2;
int grades;
}stu[100010],d;
bool higher(Student a, Student b) {
return a.grades > b.grades;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> stu[i].name1 >> stu[i].name2 >> stu[i].grades;
}
sort(stu, stu + n, higher);
cout << stu[0].name1 <<" "<< stu[0].name2 << endl;
cout << stu[n-1].name1 << " " << stu[n-1].name2 << endl;
system("pause");
return 0;
}