BreadC @ 2024-12-04 18:15:49
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int n, year[110], month[110], day[110];
cin >> n;
string name[110];
for (int i = 0; i < n; i++)
cin >> name[i] >> year[i] >> month[i] >> day[i];
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1 - i; j++)
{
if (year[j] > year[j + 1])
{
swap(name[j], name[j + 1]);
swap(year[j], year[j + 1]);
swap(month[j], month[j + 1]);
swap(day[j], day[j + 1]);
}
else if (year[j] == year[j + 1])
{
if (month[j] > month[j + 1])
{
swap(name[j], name[j + 1]);
swap(year[j], year[j + 1]);
swap(month[j], month[j + 1]);
swap(day[j], day[j + 1]);
}
else if (month[j] == month[j + 1])
{
if (day[j] > day[j + 1])
{
swap(name[j], name[j + 1]);
swap(year[j], year[j + 1]);
swap(month[j], month[j + 1]);
swap(day[j], day[j + 1]);
}
}
}
}
}
for (int i = 0; i < n; i++)
cout << name[i] << endl;
return 0;
}
by Finner_forgeter @ 2024-12-04 18:53:12
定结构体就行,用一维太麻烦
by CZY130310 @ 2024-12-15 19:59:04
666