Advertisement
Guest User

bai_4

a guest
Oct 15th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement