洛谷1104 生日
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int N = 110;
int n;
struct student
{
string s;
int num;
int y;
int m;
int d;
}stu[N];
bool cmp(student a,student b)
{
if(a.y != b.y) return a.y < b.y;
else if(a.m != b.m) return a.m < b.m;
else if(a.d != b.d) return a.d < b.d;
else return a.num > b.num;
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> stu[i].s >> stu[i].y >> stu[i].m >> stu[i].d;
stu[i].num = i;
}
sort(stu + 1, stu + n + 1, cmp);
for(int i = 1; i <= n; i ++) cout << stu[i].s << endl;
return 0;
}
和1093异曲同工 很好写