intersection cpp

Solutions on MaxInterview for intersection cpp by the best coders in the world

showing results for - "intersection cpp"
Neele
27 Jul 2016
1#include"iostream"
2
3using namespace std;
4
5
6int A[] = {2, 4, 3, 5, 6, 7};
7int B[] = {9, 2, 7, 6};
8
9int main()
10{
11    int sizeA = sizeof(A)/sizeof(int);
12
13    int sizeB = sizeof(B)/sizeof(int);
14
15    int big =  (sizeA > sizeB) ? sizeA : sizeB;
16
17    int small =  (sizeA > sizeB) ? sizeB : sizeA;
18
19    for (int i = 0; i <big ;++i)
20    {
21        for (int j = 0; j <small ; ++j)
22        {
23            if(A[i] == B[j])
24            {
25                cout<<"Element is -->"<<A[i]<<endl;
26            }
27        }
28    }
29
30    return 0;
31}
32