ghorardim

array - 2

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