Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int chuso(int n) {
- int temp;
- do {
- temp = n % 10;
- n /= 10;
- } while (n > 0);
- return temp;
- }
- bool comp(const int a, const int b) {
- return chuso(a) > chuso(b);
- }
- int main()
- {
- int n;
- int a[100];
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >>a[i];
- }
- for (int i = 0; i < n; i++)
- {
- sort(a, a + n, comp);
- }
- for (int i = 0; i < n; i++)
- {
- cout << a[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement