fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int MOD=1e9+7;
  5. int main(){
  6. string s;
  7. cin >> s;
  8. for(int i=0 ; i<s.size() ;i++){
  9. int max=i;
  10. for(int j=i+1 ; j<s.size() ; j++){
  11. if(s[j] > s[max]){
  12. max=j;
  13. }
  14. }
  15. if(s[i] < s[max]){
  16. swap(s[i] ,s[max]);
  17. break;
  18. }
  19. }
  20. cout << s;
  21. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty