fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. vector<int> a = { 0, 1, 2, 3, 4 };
  11. vector<int> &c = a;
  12.  
  13. for(auto i: a) cout << i << " "; cout << endl;
  14.  
  15. swap(c[2],c[3]);
  16.  
  17. for(auto i: a) cout << i << " "; cout << endl;
  18.  
  19. }
  20.  
  21.  
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
0 1 2 3 4 
0 1 3 2 4