fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include<string.h>
  4. #include<stdio.h>
  5. void move(char s[])
  6. {
  7. int n=strlen(s);
  8. int i=0,j=0;
  9. for(;i<=n;)
  10. {
  11. if(s[i]==' ')
  12. i++;
  13. else
  14. {swap(s[i],s[j]);
  15. i++;
  16. j++;
  17. }
  18. }
  19.  
  20. }
  21. int main() {
  22. char s[256];
  23. cin.getline(s,256);
  24. cout<<s<<endl;
  25. cout<<"spaces moved to end";
  26. move(s);
  27. printf("%s\n",s);
  28. // your code goes here
  29. return 0;
  30. }
Success #stdin #stdout 0s 3416KB
stdin
hi thisis me
g
stdout
hi thisis me
spaces moved to endhithisisme