wendi_babasituo @ 2023-08-09 08:58:39
#include<bits/stdc++.h>
using namespace std;
struct student{
string name;
int y,m,d;
}st[101];
bool cmp(student a,student b){
if(a.y==b.y){
if(a.m==b.m){
if(a.d==b.d){
return a.d>b.d;
}
return a.d<b.d;
}
return a.m<b.m;
}
return a.y<b.y;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>st[i].name>>st[i].y>>st[i].m>>st[i].d;
}
sort(st+1,st+n+1,cmp);
for(int i=1;i<=n;i++){
cout<<st[i].name<<endl;
}
}
by THE_DARK_FOREST @ 2023-08-09 09:01:25
@wendi_babasituo 你这 cmp 函数保熟吗?
by wendi_babasituo @ 2023-08-09 09:02:16
???
by 啊吧怪 @ 2023-08-09 09:02:22
@wendi_babasituo (如果有两个同学生日相同,输入靠后的同学先输出)
by wendi_babasituo @ 2023-08-09 09:03:08
so……
by 啊吧怪 @ 2023-08-09 09:04:07
@wendi_babasituo 你的结构体里面还要记录当前学生第几个输入,然后改一下 cmp
by AKPC @ 2023-08-09 09:06:43
cmp 挺奇特
by wendi_babasituo @ 2023-08-09 09:07:43
@啊吧怪 @chenyilai 谢谢AC了,关注了QWQ!!!