-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersection.cpp
49 lines (47 loc) · 889 Bytes
/
intersection.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
using namespace std;
int main()
{
int size1, size2;
int arr1[100], arr2[100];
cout << "Enter the size of Array 1 : ";
cin >> size1;
cout << "Enter the ELement of Array 1 : " << endl;
for (int i = 0; i < size1; i++)
cin >> arr1[i];
cout << "Enter the size of Array 2 : ";
cin >> size2;
cout << "Enter the ELement of Array 2 : " << endl;
for (int i = 0; i < size2; i++)
cin >> arr2[i];
cout << "INTERSECTION : " << endl;
if (size1 > size2)
{
for (int i = 0; i < size1; i++)
{
for (int j = 0; j < size1; j++)
{
if (arr1[i] == arr2[j])
{
cout << arr1[i] << " ";
break;
}
}
}
}
else
{
for (int i = 0; i < size2; i++)
{
for (int j = 0; j < size2; j++)
{
if (arr1[i] == arr2[j])
{
cout << arr2[j] << " ";
break;
}
}
}
}
return 0;
}