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
|
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <iterator>
using namespace std;
int main()
{
const int N {6};
const string s1[N] {"buffoon", "thinkers", "for", "heavy", "can", "for"};
const string s2[N] {"metal", "any", "food", "elegant", "deliver", "for"};
const set<string> A(s1, s1 + N);
const set<string> B(s2, s2 + N);
set<string> C;
set_union(A.cbegin(), A.cend(), B.cbegin(), B.cend(), insert_iterator<set<string> >(C, C.begin()));
cout << "Set C:\n";
ostream_iterator<string, char> out(cout, " ");
copy(C.begin(), C.end(), out);
return 0;
}
|