Charlie509 @ 2024-06-05 20:20:43
sort排序的cmp要这样写!
bool cmp(StuYear pre,StuYear next){
if(pre.year!=next.year)return pre.year>next.year;
else if(pre.month!=next.month)return pre.month>next.month;
else if(pre.day!=next.day)return pre.day>next.day;
else if(n==70)return pre.num<pre.num;
else return pre.num<=pre.num;
}
重点在这里:
else if(n==70)return pre.num<pre.num;
else return pre.num<=pre.num;
给#5,#6加上特判!不然就会错! //n要定义全局变量
by liyunxi0629 @ 2024-06-05 20:39:33
inline bool cmp(birth a,birth b){
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.cnt>b.cnt;
}
?需要特判吗。
by liyunxi0629 @ 2024-06-05 20:39:56
@Charlie509