提交时间:2024-05-18 17:33:32

运行 ID: 147674

#include <bits/stdc++.h> using namespace std; struct node{ string name; int year; int month; int day; int no; }a[310]; bool cmp(node x,node y){ if(x.year == y.year){ if (x.month == y.month){ if (x.day == y.day) return x.no > y.no; return x.day < y.day; } return x.month < y.month; } return x.year < y.year; } int main(){ int n; cin>>n; for(int i = 1; i <= n; i++){ cin>>a[i].name>>a[i].year>>a[i].month>>a[i].day; a[i].no = i; } sort(a + 1, a + n + 1, cmp); for(int i = 1; i <= n; i++){ cout<<a[i].name<<endl; } return 0; }