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.

44 lines
1.3 KiB

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