Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_set>
- #include <ctime>
- using namespace std;
- int main()
- {
- int k=0;
- int mas1[] = {1,2,3,4,5};
- int mas2[] = {2,4,5};
- unordered_set<int> set1 {begin(mas1), end(mas1)};
- /*for(const auto& item : set1)
- cout«item«endl;
- */
- for(const auto& item:mas2)
- {
- if (set1.find(item) != set1.end())
- k++;
- }
- cout<<"количество общих элементов = "<<k<<endl;
- cout << "runtime = " << clock()/1000.0 << endl; // время работы программы
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement