vardgrig

bilet3/3

Dec 1st, 2021
718
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <set>
  4.  
  5. std::set<int> difference(std::set<int> &s1, std::set<int> &s2) {
  6.     std::set<int> d;
  7.     std::set<int> diff;
  8.     set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(),std::inserter(diff, diff.begin()));
  9.     return diff;
  10. }
  11.  
  12. int main()  {
  13.     std::set<int> set1{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  14.     std::set<int> set2{2, 4, 6, 8, 10};
  15.     std::set<int> result;
  16.     std::set<int>::iterator it;
  17.     result = difference(set1,set2);
  18.     for (it = result.begin(); it != result.end(); ++it) std::cout << *it << " ";
  19. }
RAW Paste Data