16分求助
  • 板块P1104 生日
  • 楼主yanshuai666
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/11/23 10:54
  • 上次更新2024/11/23 13:03:22
查看原帖
16分求助
1558652
yanshuai666楼主2024/11/23 10:54
#include <bits/stdc++.h>
using namespace std;
const int N = 101001;
struct student
{
    string name;
    int num;
    int y;
    int m;
    int d;
} stu[N];
bool cmp(student a, student b)
{
    if (a.y < b.y)
        return true;
    else if (a.y > b.y)
        return false;
    else
    {
        if (a.m < b.m)
            return true;
        else if (a.m > a.m)
            return false;
        else
        {
            if (a.d < b.d)
                return true;
            else if (a.d > b.d)
                return false;
            else
            {
                if (a.num > b.num)
                    return true;
                else
                    return false;
            }
        }
    }
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> stu[i].name >> stu[i].y >> stu[i].m >> stu[i].d;
        stu[i].num = i;
    }
    sort(stu, stu + n, cmp);
    for (int i = 0; i < n; i++)
        cout << stu[i].name << endl;

    return 0;
}
2024/11/23 10:54
加载中...