a225. ๆ˜Žๆ˜Žๆ„›ๆŽ’ๅˆ— 5/16/2025

่งฃๆณ•ไธ€

โœ… ๅฎŒๆ•ดไปฃ็ขผ

่ฉ•ๅˆ†็ตๆžœ(ๅƒ่€ƒ) ๏ผš AC (5ms, 348KB)

#include <bits/stdc++.h>
using namespace std;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    while(cin >> n){
        vector<int> arr(n);

        for(int& i : arr) cin >> i;
        sort(arr.begin(), arr.end(), comp);
        
        for(int i=0; i<n; i++){
            if(i != 0) cout << " ";
            cout << arr[i];
        }
        cout << "\n";
    }

    return 0;
}