fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define endl '\n'
  4. #define int long long
  5.  
  6. const int MOD=1e9+7;
  7. const int INF=LLONG_MAX/2;
  8.  
  9. signed main() {
  10. ios::sync_with_stdio(false);cin.tie(NULL);
  11. string s;
  12. cin>>s;
  13. vector<char>arr;
  14. for(int i=0;s[i]!='\0';i++){
  15. if(s[i] != '+')arr.push_back(s[i]);
  16. }
  17. sort(arr.begin(),arr.end());
  18. for(int i=0;i<arr.size();i++){
  19. if(i==0)cout<<arr[i];
  20. else cout<<'+'<<arr[i];
  21. }
  22.  
  23.  
  24. }
Success #stdin #stdout 0.01s 5284KB
stdin
2
stdout
2