Chinese_good_FaFa @ 2024-05-26 19:23:14
本人代码:
#include<bits/stdc++.h>
using namespace std;
struct pp{
string name;
int y;
int m;
int d;
int sj;
};
bool cmp(pp a,pp b){
if(a.y!=b.y){
return a.y<b.y;
}
else if(a.m!=b.m){
return a.m<b.m;
}
else{
return a.d<b.d;
}
}
int main(){
int n;
pp a[105];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].y>>a[i].m>>a[i].d;
a[i].sj=i;
}
sort(a, a+n, cmp);
for(int i=0;i<n;i++){
cout<<a[i].name<<endl;
}
return 0;
}
目前最后一个样例WA,输入:
91
Zhaojiang 1991 1 8
Yangchu 1993 1 7
Kangyi 1993 2 9
Wangxing 1992 10 20
Liyue 1991 3 14
Qianmu 1993 1 2
Sunxian 1994 5 7
Liyue 1994 10 10
Devon 1988 1 1
Lindsay 1988 1 2
Guning 1989 12 30
Hanmei 1994 1 1
Songting 1992 6 12
Guofan 1994 5 5
Yangyu 1991 9 13
Columbia 1988 2 1
Ainey 1988 2 2
Averill 1989 2 3
Bronson 1990 2 3
Corliss 1991 3 1
Lari 1991 3 2
Ballard 1992 8 20
Brown 1994 1 17
Courtney 1989 10 17
Lark 1990 6 5
Bancroft 1988 1 10
Buck 1988 9 10
Daralis 1992 9 10
Leigh 1993 9 10
Barclay 1988 11 10
Buckley 1989 11 10
Dawn 1990 11 10
Qiujingya 1990 5 8
Luowen 1990 4 6
Heling 1990 12 11
Luopeng 1992 1 9
Pengwei 1993 2 3
Mating 1992 1 18
Chenya 1990 4 5
Tantian 1989 9 2
Leslie 1991 11 10
Barden 1992 11 10
Bud 1993 11 10
Demelza 1994 11 10
Liberty 1989 11 9
Barnett 1988 11 9
Burgess 1992 11 9
Maliang 1990 1 2
Wangxin 1992 12 3
Pangcheng 1990 7 28
Lingshuai 1991 2 9
Xiebing 1991 11 10
Yangyang 1991 3 20
Shejing 1993 9 30
Yuanhui 1992 3 3
Liufang 1993 3 30
Ansley 1993 11 9
Brishen 1994 11 9
Chelsea 1988 7 27
Kirsten 1990 7 27
Atherol 1991 7 27
Brock 1989 7 27
Claiborne 1992 7 27
Kismet 1993 7 24
Atwater 1994 7 24
Broderick 1990 2 14
Clovis 1991 3 13
Kyla 1990 1 19
Twood 1991 1 19
Bromley 1992 1 19
Micheal 1988 2 28
Mich 1989 2 28
Richer 1990 2 27
Ownes 1991 2 27
Shouler 1992 12 10
Akai 1993 12 10
Pardo 1994 12 10
Surse 1989 12 10
Tia 1988 12 10
Laise 1988 4 4
Yila 1989 4 4
Mcial 1990 4 4
Nipa 1991 4 4
Bedge 1992 4 4
Colece 1993 4 4
Zipoe 1994 4 4
Geman 1988 6 30
Locuy 1989 6 30
Kacue 1990 6 30
Vocae 1992 6 30
Huafer 1993 6 30
输出:
Devon
Lindsay
Bancroft
Columbia
Ainey
Micheal
Laise
Geman
Chelsea
Buck
Barnett
Barclay
Tia
Averill
Mich
Yila
Locuy
Brock
Tantian
Courtney
Liberty
Buckley
Surse
Guning
Maliang
Kyla
Bronson
Broderick
Richer
Mcial
Chenya
Luowen
Qiujingya
Lark
Kacue
Kirsten
Pangcheng
Dawn
Heling
Zhaojiang
Twood
Lingshuai
Ownes
Corliss
Lari
Clovis
Liyue
Yangyang
Nipa
Atherol
Yangyu
Xiebing
Leslie
Luopeng
Mating
Bromley
Yuanhui
Bedge
Songting
Vocae
Claiborne
Ballard
Daralis
Wangxing
Burgess
Barden
Wangxin
Shouler
Qianmu
Yangchu
Pengwei
Kangyi
Liufang
Colece
Huafer
Kismet
Leigh
Shejing
Ansley
Bud
Akai
Hanmei
Brown
Zipoe
Guofan
Sunxian
Atwater
Liyue
Brishen
Demelza
Pardo
救救孩子吧
by Qiu101029 @ 2024-05-26 20:32:38
@sunny_town 如果有两个同学生日相同,输入靠后的同学先输出(题目中的),并且结构体排序时没用到sj这个变量
by Chinese_good_FaFa @ 2024-05-26 21:15:11
@Qiu101029
by Chinese_good_FaFa @ 2024-05-26 21:54:41