#19819: C++ sort+compare


jack621224 (YJLegend)

學校 : 政治大學
編號 : 74898
來源 : [140.113.213.67]
最後登入時間 :
2023-10-06 04:18:11
a225. 明明愛排列 | From: [140.119.121.6] | 發表日期 : 2019-11-02 15:46

使用comp來sort

bool comp(int a, int b){
     if(a%10==b%10) return a>b;
     else return a%10<b%10;
}

 

sort(arr, arr+n, comp);

 

剛學會compare覺得酷

 
#20633: Re:C++ sort+compare


babylinlin (babylinlin)

學校 : 不指定學校
編號 : 114884
來源 : [114.34.229.248]
最後登入時間 :
2020-02-18 23:10:15
a225. 明明愛排列 | From: [211.21.176.130] | 發表日期 : 2020-02-14 22:31

使用comp來sort

bool comp(int a, int b){
     if(a%10==b%10) return a>b;
     else return a%10<b%10;
}

 

sort(arr, arr+n, comp);

 

剛學會compare覺得酷



你的眼睛背叛了你的心~~~~~~

 
ZeroJudge Forum