Guest User

Untitled

a guest
Oct 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. void process(int array[250] , int length){
  7.  
  8. sort(array , array + length);
  9.  
  10. for(int i = 0 ; i < length ; i++){
  11.  
  12. cout << array[i];
  13.  
  14. if(i == length - 1){
  15.  
  16. break;
  17.  
  18. }
  19.  
  20. cout << "+";
  21. }
  22.  
  23. }
  24.  
  25. int main() {
  26.  
  27. string series;
  28.  
  29. int countPlus = 0;
  30.  
  31. int array[250];
  32.  
  33. cin >> series;
  34.  
  35. int length = series.length();
  36.  
  37. if(length <= 100){
  38.  
  39. for(int i = 0 ; i < length ; i++){
  40.  
  41. if(series.at(i) == '+'){
  42.  
  43. countPlus++;
  44.  
  45. }
  46.  
  47. if(series.at(i) != '+'){
  48.  
  49. array[i - countPlus] = series.at(i) - 48;
  50.  
  51. }
  52.  
  53. }
  54.  
  55. int len = length - countPlus;
  56.  
  57. process(array , len);
  58.  
  59. }else{
  60.  
  61. exit(0);
  62.  
  63. }
  64. return 0;
  65. }
Add Comment
Please, Sign In to add comment