SHARE
TWEET

bai_4

a guest Oct 15th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. int chuso(int n) {
  5.     int temp;
  6.     do {
  7.         temp = n % 10;
  8.         n /= 10;
  9.     } while (n > 0);
  10.     return temp;
  11. }
  12. bool comp(const int a, const int b) {
  13.     return chuso(a) > chuso(b);
  14. }
  15. int main()
  16. {
  17.     int n;
  18.     int a[100];
  19.     cin >> n;
  20.     for (int i = 0; i < n; i++)
  21.     {
  22.         cin >>a[i];
  23.     }
  24.     for (int i = 0; i < n; i++)
  25.     {
  26.         sort(a, a + n, comp);
  27.     }
  28.     for (int i = 0; i < n; i++)
  29.     {
  30.         cout << a[i];
  31.     }
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top