fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void Interleave(string s)
  4. {
  5. int left = 1;
  6. int right = s.length()/2;
  7. int temp;
  8. while (left < right)
  9. {
  10. for (int i = right; i > left; i--)
  11. {
  12. temp = s[i];
  13. s[i] = s[i - 1];
  14. s[i - 1] = temp;
  15. }
  16. left += 2;
  17. right += 1;
  18. }
  19. cout<<s<<endl;
  20. }
  21. int main(){
  22. string s="abcdefgh";
  23. Interleave(s);
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
aebfcgdh