1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int setA[5] = {2,4,5,7,8};
int setB[7] = {3,4,5,6,7,8,10};
int setC[5] = {1,5,6,8,15};
int AdifferenceC[5];
int BsymdiffC[10];
int *lastElem;
ostream_iterator<int> print(cout, " ");
cout << "setA = ";
copy(setA, setA + 5, print);
cout << endl;
cout << "setB = ";
copy(setB, setB + 7, print);
cout << endl;
cout << "setC = ";
copy(setC, setC + 5, print);
cout << endl;
lastElem = set_difference(setA, setA + 5, setC, setC, + 5, AdifferenceC);
cout << "set AdifferenceC = ";
copy(AdifferenceC, lastElem, print);
cout << endl;
return 0;
}
|