AC代码
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
string s;
int n,y,r,sh;
}a[2005];
bool cmp(node a,node b){//结构体的cmp
if(a.n<b.n){
return 1;
}
else if(a.n==b.n&&a.y<b.y){
return 1;
}
else if(a.n==b.n&&a.y==b.y&&a.r<b.r){
return 1;
}
else if(a.n==b.n&&a.y==b.y&&a.r==b.r&&a.sh>b.sh){
return 1;
}
else{
return 0;
}
}
int main(){
int h;
cin>>h;
for(int i=1;i<=h;i++){
cin>>a[i].s>>a[i].n>>a[i].y>>a[i].r;
a[i].sh=i;
}
sort(a+1,a+1+h,cmp);//排序
for(int i=1;i<=h;i++){
cout<<a[i].s<<endl;
}
return 0;
}