是相同年龄,序号后的先输出,不是序号先的先输出。交n遍错n遍……
#include <bits/stdc++.h>
using namespace std;
struct ss {
string name;
long long br=0,xh;
} wh[666];
bool cmp(ss z,ss x) {
if(z.br!=x.br)
return z.br<x.br;
else
return z.xh>x.xh;
}
int main() {
long long a,y,m,d;
cin>>a;
for(int i=1; i<=a; i++) {
cin>>wh[i].name>>y>>m>>d;
wh[i].br+=y*10000;
wh[i].br+=m*100;
wh[i].br+=d;
wh[i].xh=i;
}
sort(wh+1,wh+a+1,cmp);
for(int i=1; i<=a; i++) {
cout<<wh[i].name<<endl;
}
return 0;
}