fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <set>
  5. #include <algorithm>
  6. void dothis()
  7. {
  8. std::istringstream afile ("1 2 10\n\n 15\n 2 5 ");
  9. std::istream_iterator<int> abeg(afile), aend;
  10. std::set<int> aset(abeg, aend);
  11.  
  12. std::istringstream gfile ("10 11 100 -1 0\n1 2 5\n");
  13. std::istream_iterator<int> gbeg(gfile), gend;
  14. std::set<int> gset(gbeg, gend);
  15.  
  16. // no files on ideone, using strings and cout
  17. // std::ofstream cfile("c.txt");
  18. set_symmetric_difference(aset.begin(), aset.end(),
  19. gset.begin(), gset.end(),
  20. std::ostream_iterator<int>(std::cout, "\n"));
  21. }
  22. int main()
  23. {
  24. dothis();
  25. }
  26.  
Success #stdin #stdout 0.01s 2864KB
stdin
Standard input is empty
stdout
-1
0
11
15
100