为什么,求助

P1104 生日

Everyday_yx @ 2024-07-12 23:53:24

80分???

#include <iostream>
#include <algorithm>
using namespace std;

struct people {
    string name;
    int year;
    int month;
    int day;
} p[110];

bool cmp(people a, people b) {
    if (a.year != b.year) {
        return a.year < b.year;
    } else if (a.month != b.month) {
        return a.month < b.month;
    } else {
        return a.day < b.day;
    }
}

int main() {
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> p[i].name >> p[i].year >> p[i].month >> p[i].day;
    }

    sort(p, p + n, cmp);

    for (int i = 0; i < n; i++) {
        cout << p[i].name << endl;
    }

    return 0;
}

by NullPointerExpection @ 2024-07-13 07:48:51

如果有两个同学生日相同,输入靠后的同学先输出 @Everyday_yx


|