#30996: 用sort自己寫cmp比較簡單


(unknown)

School : No School
ID : 0
IP address : []
Last Login :
2023-03-28 22:19:11
a225. 明明愛排列 | From: [220.157.123.53] | Post Date : 2022-07-01 03:03

#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
    if(a%10==b%10)return a>b;
    else return (a%10)<(b%10);
}
int main(){
    int n;
    while(cin>>n){
        int k;
        vector<int> s;
        for(int i=0;i<n;i++){
            cin>>k;
            s.push_back(k);
        }
        sort(s.begin(),s.end(),cmp);
        for(auto j:s)cout<<j<<" ";
        cout<<endl;
    }
    return 0;
}

 
ZeroJudge Forum