You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
struct Student {
string name;
int height;
string num;
};
//对比的方法
/*
,
*/
bool compare(const Student &x, const Student &y) {
if (x.height == y.height) return x.num < y.num;
return x.height > y.height;
}
int main() {
int n;
cin >> n;
//声明动态数组
Student *a = new Student[n];
for (int i = 0; i < n; ++i) {
cin >> a[i].name >> a[i].height >> a[i].num;
}
/*
3
1
2n
3sort1,2,3,4
4,3,2,1
*/
sort(a, a + n, compare);
//输出结果
cout << a[0].name << " " << a[0].height << " " << a[0].num << endl;
//删除动态数组
delete[]a;
return 0;
}