DKsniper @ 2024-01-24 09:56:55
#include<bits/stdc++.h>
using namespace std;
int n;
struct l{
string name;
int y,m,d,xh;
}a[110];
int cmp(l x,l y){
if(x.y<y.y){
if(x.m<y.m){
if(x.d<y.d)
return x.xh<y.xh;
return x.d>y.d;
}
return x.m>y.m;
}
return x.y>y.y;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].name>>a[i].y>>a[i].m>>a[i].d;
a[i].xh=i;
}
sort(a+1,a+1+n,cmp);
for(int i=n;i>=1;i--) cout<<a[i].name<<endl;
return 0;
}
by naoliaok_lovely @ 2024-01-24 10:00:44
int cmp(l x,l y){
if(x.y!=y.y){
if(x.m!=y.m){
if(x.d!=y.d)
return ?;
return ?;
}
return ?;
}
return ?;
}
by MikeYSYoung__0419 @ 2024-01-24 10:23:55
这个cmp是比较函数吗
by _Clown__ @ 2024-01-24 10:29:07
if(a.y!=b.y)
return a.y<b.y;
if(a.m!=b.m)
return a.m<b.m;
if(a.d!=b.d)
return a.d<b.d;
return a.xh>b.xh;
by _Clown__ @ 2024-01-24 10:29:45
a,b理解为你的x,y
by DKsniper @ 2024-01-24 11:07:53
已经自己A了,谢谢大佬
@_Clown__ @MikeYSYoung__0419 @naoliaok_lovely