kkkllj @ 2023-10-28 09:28:57
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef struct t_data
{
string s;
int y, m, d, ind;
} data;
data datas[105];
bool cmp(data &a, data &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.m == b.m && a.d != b.d)
return a.d < b.d;
else if (a.m == b.m && a.d == b.d)
return a.ind > b.ind;
}
}
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> datas[i].s >> datas[i].y >> datas[i].m >> datas[i].d;
datas[i].ind = i;
}
sort(datas, datas + n, cmp);
for (int i = 0; i < n; i++)
{
cout << datas[i].s << endl;
}
return 0;
}
by _LX_ @ 2023-10-28 09:32:05
@kkkllj 不能用data作结构体名,有歧义
by kkkllj @ 2023-10-28 10:45:10
@_LX_过了!!!感谢大佬