fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main(void)
  7. {
  8. string number;
  9. int arr[10] = { 0, };
  10. cin >> number;
  11.  
  12. for (int i = 0; i < number.length(); i++)
  13. arr[number[i] - '0']++;
  14.  
  15. for (int i = 9; i >= 0; i--)
  16. for (int j = 0; j < arr[i]; j++)
  17. cout << i;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 4600KB
stdin
2143
stdout
4321