fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. int main() {
  6. std::vector<int> a{6, 10, 14, 20};
  7. std::vector<int> b{4, 8, 16, 20};
  8.  
  9. a.insert(a.end(), b.begin(), b.end());
  10.  
  11. std::sort(a.begin(), a.end());
  12. auto last = std::unique(a.begin(), a.end());
  13. a.erase(last, a.end());
  14.  
  15. for(auto e: a) {
  16. std::cout << e << ' ';
  17. }
  18. std::cout << '\n';
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
4 6 8 10 14 16 20