Skip to content

Commit

Permalink
Added Union of two array Program from C++ language
Browse files Browse the repository at this point in the history
  • Loading branch information
SHARMA-SAURAV committed Oct 10, 2022
1 parent ec55a10 commit 2a8a72c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.DS_Store
*.idea*
.github
*.github/
*.github/
/.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include <bits/stdc++.h>

using namespace std;
void getUnion(int a[], int n, int b[], int m)
{
set<int> s;
for (int i = 0; i < n; i++)
s.insert(a[i]);

for (int i = 0; i < m; i++)
s.insert(b[i]);
cout << "Number of elements after union operation: " << s.size() << endl;
cout << "The union set of both arrays is :" << endl;
for (auto itr = s.begin(); itr != s.end(); itr++)
cout << *itr
<< " ";
}

int main()
{
int a[9] = { 1, 2, 5, 6, 2, 3, 5, 7, 3 };
int b[10] = { 2, 4, 5, 6, 8, 9, 4, 6, 5, 4 };

getUnion(a, 9, b, 10);
}

0 comments on commit 2a8a72c

Please sign in to comment.