yanleyang @ 2024-10-17 13:40:27
#include<bits/stdc++.h>
using namespace std;
struct student
{
string name;
int year;
int month;
int day;
int sum;
}person[110];
int yyear,mmonth,dday,ssum;
string nname;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>person[i].name>>person[i].year>>person[i].month>>person[i].day;
person[i].sum=i;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n-1;j++)
{
if(person[j].year>person[j+1].year)
{
nname=person[j].name;yyear=person[j].year;mmonth=person[j].month;dday=person[j].day;
person[j].name=person[j+1].name;person[j].year=person[j+1].year;person[j].month=person[j+1].month;person[j].day=person[j+1].day;
person[j+1].name=nname;person[j+1].year=yyear;person[j+1].month=mmonth;person[j+1].day=dday;
}
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n-1;j++)
{
if(person[i].year==person[i+1].year && person[i].month==person[i+1].month && person[i].day==person[i+1].day && person[i].sum>person[i+1].sum)
{
nname=person[i].name;yyear=person[j].year;mmonth=person[j].month;dday=person[j].day;ssum=person[j].sum;
person[j]=person[j+1];
person[j+1].name=nname;person[j+1].year=yyear;person[j+1].month=mmonth;person[j+1].day=dday;person[j+1].sum=ssum;
}
}
}
for(int i=0;i<n;i++)
{
cout<<person[i].name<<endl;
}
return 0;
}