Implement a function that finds union of two sets. You can assume that the sets
are stored using arrays. So, if array1 = {1,2,3,4,5,6,3,2} and array2 is {1,3,5,7}, then
array3 should be {1,2,3,4,5,6,7}. Note array3 should not have any duplicate elements. You
have to:
think of all the functions that are required for this problem. Each function should perform
its dedicated task. So, plan them out before implementing them.
Main should only have a set of function calls.
in c++
#include
using namespace std;
int main(){
int arr_1[8]={1,2,3,4,5,6,3,2};
int arr_2[4]={1,3,5,7};
int arr_3[8];
int i;
for(int i=0; i<8; i++){
for(int j=0; j<4; j++){
if(arr_1[i]!=arr_2[j]){
arr_3[8]=arr_1[i];
}
}
}
return 0;
}
JACK MORTON is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.