#include <iostream> using namespace std; #include <algorithm> #include <set> #include <vector> int tab1[] = { 2, 3, 4, 6, 8 }; int tab2[] = { 1, 3, 5 }; int main() { set<int> set1(tab1, tab1+5); set<int> set2(tab2, tab2+3); ostream_iterator< int > output( cout, " " ); cout<<"Set1: "; copy( set1.begin(), set1.end(), output ); cout << endl; cout<<"Set2: "; copy( set2.begin(), set2.end(), output ); cout << endl; vector<int> sym_diffre; set_symmetric_difference(set1.begin(),set1.end(), set2.begin(), set2.end(), back_inserter(sym_diffre)); copy(sym_diffre.begin(), sym_diffre.end(), output); return 0; } |
----------------------------------------------------------------------------