Advertisement
Md_hosen_zisad

common elements from two array

Sep 24th, 2017
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. int arr[1000],arr2[1000];
  3. int main()
  4. {
  5. int i,n;
  6. scanf("%d",&n);
  7.  
  8. for(i=0;i<n;i++)
  9. {
  10.    int x;
  11.    scanf("%d",&x);
  12.    arr[x]=1;
  13. }
  14.  
  15. for(i=0;i<n;i++)
  16. {
  17.    int x;
  18.    scanf("%d",&x);
  19.    arr2[x]=1;
  20. }
  21.  
  22.  
  23. for(i=0;i<1000;i++)
  24. {
  25.     if(arr[i] == arr2[i] && arr[i]==1) printf("%d ",i);
  26. }
  27. return 0;
  28.  
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement