Advertisement
LegoDrifter

Nizi - detektor na duplikati megju dve nizi

Dec 30th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void main()
  4. {
  5.     int niza1[100];
  6.     int niza2[100];
  7.     int niza3[100];
  8.     int n,i,j,detektor,duplikati=0;
  9.     scanf("%d",&n);
  10.     for(i=0;i<n;i++)
  11.     {
  12.         scanf("%d",&niza1[i]);
  13.     }
  14.     for(i=0;i<n;i++)
  15.     {
  16.         niza2[i]=niza1[i];
  17.         niza3[i]=0;
  18.     }
  19.     for(i=0;i<n;i++)
  20.     {
  21.         for(j=0;j<n;j++)
  22.         {
  23.             if(niza1[i]==niza2[j])
  24.             {
  25.                 niza3[j]=detektor;
  26.                 detektor++;
  27.             }
  28.  
  29.         }
  30.         detektor=1;
  31.     }
  32.     for(i=0;i<n;i++)
  33.     {
  34.         if(niza3[i]==2)
  35.         {
  36.             duplikati++;
  37.         }
  38.     }
  39.     printf("Imame %d duplikati \n",duplikati);
  40.  
  41.  
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement