PROGRAM :
Code:
#include<algorithm>
#include<set>
#include <istream.h>
using namespace std;
int main()
{
int B1[] = {1,3,5,7,9,11};
int B3[] = {3,5,7,8};
set<int, less<int> > od(B1+0,B1+6), rslt,
small(B3+0,B3+4);
insert_iterator<set<int, less<int> > >
res_ins(rslt, rslt.begin());
cout << "The symmetric difference of:" << endl << "{";
copy(small.begin(),small.end(),
ostream_iterator<int,char>(cout," "));
cout << "} with {";
copy(od.begin(),od.end(),
ostream_iterator<int,char>(cout," "));
cout << "} =" << endl << "{";
set_symmetric_difference(small.begin(), small.end(),
od.begin(), od.end(), res_ins);
copy(rslt.begin(),rslt.end(),
ostream_iterator<int,char>(cout," "));
cout << "}" << endl << endl;
return 0;
}
Program Output :
Code:
The symmetric difference of:
{3 5 7 8 } with {1 3 5 7 9 11 } =
{1 8 9 11 }
Bookmarks