fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main([[maybe_unused]] int argc,
  10. [[maybe_unused]] const char * argv[])
  11. {
  12. vector<int> a{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  13.  
  14. for(int i = 0, j = 4; i < j; ++i, --j) swap(a[i],a[j]);
  15. for(int i = 5, j = 19; i < j; ++i, --j) swap(a[i],a[j]);
  16. for(int i = 0, j = 19; i < j; ++i, --j) swap(a[i],a[j]);
  17.  
  18. for(int i: a) cout << i << " ";
  19.  
  20.  
  21. }
  22.  
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5