fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. void print(const std::vector<int>& vec) {
  5. for(int el : vec)
  6. std::cout << el << " ";
  7. std::cout << std::endl;
  8. }
  9.  
  10. int main() {
  11. std::vector<int> vec = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  12.  
  13. print(vec);
  14. std::swap(vec[1], vec[4]);
  15. std::swap(vec[5], vec[8]);
  16. print(vec);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 4356KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9 
0 4 2 3 1 8 6 7 5 9