fork(1) download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. const int N = 5;
  8. int a[] = {1,2,3,4,5,6,7,8,9,10};
  9.  
  10. for_each(a, a+N, [](auto &x){swap(x,*(&x+N)); } );
  11. for_each(a, a+2*N, [](auto x){cout << x<<" "; } );
  12. return 0;
  13. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
6 7 8 9 10 1 2 3 4 5