vardgrig

bilet1/3

Dec 1st, 2021
695
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. std::set<int> Union(std::set<int>& s1,std::set<int>& s2) {
  8.     std::set<int> s;
  9.     std::set_union(s1.begin(), s1.end(),s2.begin(), s2.end(), std::inserter(s,s.begin()));
  10.     return s;
  11. }
  12.  
  13. int main() {
  14.     std::set<int> s1;
  15.     std::set<int> s2;
  16.     std::set<int>::iterator it;
  17.     s1.insert(1);
  18.     s1.insert(2);
  19.     s1.insert(3);
  20.     s1.insert(4);
  21.     s2.insert(5);
  22.     s2.insert(6);
  23.     s2.insert(7);
  24.     s2.insert(8);
  25.     std::set<int> result = Union(s1,s2);
  26.     for (it = result.begin(); it != result.end(); ++it) std::cout << *it << " ";
  27. }
RAW Paste Data