P1104 生日


题目传送门

#include 

using namespace std;
const int N = 110;
struct Student {
    string Name;
    int year, month, day, num;
} a[N];

bool cmp(const Student &a, const Student &b) {
    if (a.year == b.year)
        if (a.month == b.month)
            if (a.day == b.day)
                return a.num > b.num;
            else
                return a.day < b.day;
        else return a.month < b.month;
    else return a.year < b.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].num = i;
    }
    sort(a + 1, a + 1 + n, cmp);

    for (int i = 1; i <= n; i++)        cout << a[i].Name << endl;
    return 0;
}