The following program can demonstrates you how to implement the set_union() function of the C++ language in the C++ programming as follows :
Code:
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
int fst[] = {15,1,5,2,6};
int scnd[] = {5,4,3,2,1};
vector<int> w(10);
vector<int>::iterator t;
sort (fst,fst+5);
sort (scnd,scnd+5);
t=set_union (fst, fst+5, scnd, scnd+5, w.begin());
cout << "union has " << int(t - w.begin()) << " elements.\n";
return 0;
}
Output:
Code:
union has 8 elements
Bookmarks