fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. string moveAllX(string s)
  5. {
  6. if(s.length()==0)
  7. {
  8. return " ";
  9. }
  10. char ch=s[0];
  11. string ans = moveAllX(s.substr(1));
  12. if(ch=='x')
  13. return(ans+ch);
  14. else
  15. return(ch+ans);
  16. }
  17. int main()
  18. {
  19. cout<<moveAllX("axxbdxcefxhix");
  20. }
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
abdcefhi xxxxx