fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4.  
  5.  
  6. int main()
  7. {
  8. int nums[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  9. std::vector<int> u(std::begin(nums), std::end(nums));
  10. std::list<int> v(std::begin(nums), std::end(nums));
  11.  
  12. for (auto it = u.begin(); it != u.end(); ++it)
  13. if (*it % 2 == 0)
  14. it = u.erase(it);
  15. for (auto it = v.begin(); it != v.end(); ++it)
  16. if (*it % 2)
  17. it = v.erase(it);
  18.  
  19. for (auto &i : u)
  20. std::cout << i << " ";
  21. std::cout << std::endl;
  22. for (auto &i : v)
  23. std::cout << i << " ";
  24. std::cout << std::endl;
  25. }
  26.  
Runtime error #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Standard output is empty