fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. vector<char>v;
  8. char ch;
  9. int l, r;
  10. cin >> l >> r;
  11. while(cin >> ch){
  12. v.push_back(ch);
  13. }
  14. int mid = (l+r) / 2;
  15. for (int i=0; i<=mid; i++){
  16. char temp;
  17. temp = v[l-1+i];
  18. v[l-1+i] = v[r-1-i];
  19. v[r-1-i] = temp;
  20. }
  21. for (char u:v)
  22. cout << u << endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5288KB
stdin
3 7
abcdefgh
stdout
a
h
c
d
e
f
g
b