Skip to content

Commit

Permalink
Merge pull request #54 from YASHYK47/master
Browse files Browse the repository at this point in the history
Solved Issue #13
  • Loading branch information
anmolrishi authored Oct 27, 2018
2 parents 90ab89b + 076ef47 commit 9b32dbe
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Array Intersection
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{ int m,n,i,s,k=0;
scanf("%d%d",&m,&n);//m for first array, n for second array
if(m<n)
s=m;
else s=n;
int A[m],B[n],j,C[s];
for(i=0;i<m;i++)
scanf("%d",&A[i]);
for(i=0;i<n;i++)
scanf("%d",&B[i]);
i=0;j=0;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{if(A[i]==B[j])
{ C[k]=A[i];k++;
}
}
printf("\nIntersection contains-\n");
for(i=0;i<s;i++)
printf("%d ",C[i]);
return 0;
}

0 comments on commit 9b32dbe

Please sign in to comment.