fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <string>
  5. #include <vector>
  6. #include <set>
  7. using namespace std;
  8.  
  9. int main(int argc,char *argv[])
  10. {
  11. vector<string> a { "aaa","xxx","bbb","ccc"};
  12. vector<string> b { "aaa","bbb","yyy","ccc"};
  13. set<string> ab(a.begin(),a.end());
  14. for(auto s:b) ab.erase(s);
  15. set<string> ba(b.begin(),b.end());
  16. for(auto s:a) ba.erase(s);
  17. for(auto s:ba) ab.insert(s);
  18. copy(ab.begin(),ab.end(),ostream_iterator<string>(cout," "));
  19. return 0;
  20. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
xxx yyy