SHARE
TWEET

VKbase2

tantarin May 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <unordered_set>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int k=0;
  9. int mas1[] = {1,2,3,4,5};
  10.  
  11. int mas2[] = {2,4,5};
  12.  
  13.  
  14. unordered_set<int> set1 {begin(mas1), end(mas1)};
  15.  
  16. /*for(const auto& item : set1)
  17. cout«item«endl;
  18. */
  19. for(const auto& item:mas2)
  20. {
  21. if (set1.find(item) != set1.end())
  22. k++;
  23. }
  24. cout<<"количество общих элементов = "<<k<<endl;
  25. cout << "runtime = " << clock()/1000.0 << endl; // время работы программы
  26.  
  27. return 0;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top