Intersection
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,i,j,f=1;
cout<<"Enter the size of first array :";
cin>>x;
cout<<"Enter the size of second array :";
cin>>y;
int a[x], b[y];
cout<<"Enter the elements of first array :";
for(i=0;i<x;i++)
cin>>a[i];
cout<<"Enter the elements of second array :";
for(i=0;i<y;i++)
cin>>b[i];
for(i=0;i<x;i++)
for(j=0;j<y;j++)
if(a[i]==b[j])
{cout<<a[i]<<" ";f=0;}
if(f==1)
cout<<"NO common elements !";
}
Comments
Post a Comment