代码如下:
#define MAX_VAL 100+5
#include <bits/stdc++.h>
using namespace std;
int n,m;
class student{
public:
int id,year,mooth,day;
string name;
};
student stus[MAX_VAL];
bool cmp(student& a,student& b){
if(a.year!=b.year) return a.year<b.year;
if(b.mooth!=b.mooth) return a.mooth<b.mooth;
if(a.day!=b.day) return a.day<b.day;
return a.id>b.id;
}
int main(int arg,char **argv){
cin>>n;
for(int i=0;i<n;i++){
cin>>stus[i].name;
cin>>stus[i].year>>stus[i].mooth>>stus[i].day;
stus[i].id = i;
}
sort(stus,stus+n,cmp);
for(int i=0;i<n;i++)
cout<<stus[i].name<<endl;
return 0;
}