zhangyichen666 @ 2024-07-12 16:39:56
#include<bits/stdc++.h>
using namespace std;
struct ms{
string mz;
int nian,yue,ri;
};
ms r[110];
int rs;
bool cmp(ms x,ms y){
if(x.nian==y.nian&&x.yue==y.yue&&x.ri==y.ri){
return 1;
}
if(x.nian==y.nian&&x.yue==y.yue){
return x.ri<y.ri;
}
if(x.nian==y.nian){
return x.yue<y.yue;
}
return x.nian<y.nian;
}
int main(){
cin>>rs;
for(int i=1;i<=rs;i++){
cin>>r[i].mz>>r[i].nian>>r[i].yue>>r[i].ri;
}
sort(r+1,r+1+rs,cmp);
for(int i=1;i<=rs;i++){
cout<<r[i].mz<<"\n";
}
return 0;
}
by _buzhidao_ @ 2024-07-12 16:45:11
@zhangyichen666
如果有两个同学生日相同,输入靠后的同学先输出
结构体变量增加一个输入次序,以此排序。return 1
不行。
by zhangyichen666 @ 2024-07-12 17:45:47
谢谢大佬