Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <set>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int n, m, number;
- cin >> n >> m;
- set<int> numbers1;
- set<int> numbers2;
- for (int i = 0; i < n + m; i++) {
- cin >> number;
- i < n ? numbers1.insert(number) : numbers2.insert(number);
- }
- vector<int> numbers3;
- set_intersection(numbers1.begin(), numbers1.end(), numbers2.begin(), numbers2.end(), back_inserter(numbers3));
- for (auto& n : numbers3) {
- cout << n << ' ';
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement