fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. string s;
  11. cin>>s;
  12. int k=0,l=s.size(),f=1,t=l/2;
  13. string a;
  14. a=s;
  15. for(int i=0;s[i];i++)
  16. {
  17. if(f)
  18. {
  19. a[t+k]=s[i];
  20. k++;
  21. f=1-f;
  22. }
  23. else
  24. {
  25. a[t-k]=s[i];
  26. f=1-f;
  27. }
  28. }
  29. //if(l%2==0)
  30. // reverse(a.begin(),a.end());
  31. cout<<a<<endl;
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 16064KB
stdin
3
hoct
ohtcu
abba
stdout
tohc
chotu
abab