fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 100;
  5. const int MAX_VAL = 1000000;
  6. const int TEN = 10;
  7.  
  8. int main() {
  9. int n, newArray[MAX_VAL + 1], freq[MAX_VAL];
  10. long long v[MAX_LENGTH + 1];
  11. cin >> n;
  12. for (int i = 1; i <= n; ++i) {
  13. cin >> v[i];
  14. long long aux = v[i], index = 0;
  15. if (v[i] == 0) {
  16. cout << "0";
  17. }
  18. while (aux) {
  19. newArray[index++] = aux % TEN;
  20. aux /= TEN;
  21. }
  22. for (int i = 0; i < index; ++i) {
  23. ++freq[newArray[i]];
  24. }
  25. int flag = 1;
  26. for (int i = 1; i < 10; ++i) {
  27. while (freq[i] || freq[0] > 0) {
  28. if (flag == 1 && freq[i] > 0) {
  29. cout << i;
  30. --freq[i];
  31. }
  32. if (freq[0] > 0) {
  33. cout << "0";
  34. --freq[0];
  35. flag = 0;
  36. } else {
  37. flag = 1;
  38. }
  39. if (freq[0] == 0) {
  40. //flag = 1;
  41. }
  42. }
  43. //cout << freq[i] <<" ";
  44. }
  45.  
  46.  
  47.  
  48. cout << " ";
  49. }
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0.01s 5592KB
stdin
1
1000000000 
stdout
1000000000