fork(1) download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. int main() {
  7. std::vector<int> a = {1,2,3,4,5,5};
  8. std::vector<int> b = {5,5,5,5,4};
  9. std::vector<int> c;
  10.  
  11. std::sort(a.begin(), a.end());
  12. std::sort(b.begin(), b.end());
  13. std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(c));
  14.  
  15. for (auto &x : c) {
  16. std::cout << x << std::endl;
  17. }
  18. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
4
5
5