Facebook
From Ryuujin, 9 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 736
  1.        
  2.  
  3.     #include <stdio.h>
  4.     #include <stdlib.h>
  5.      
  6.     int main()
  7.     {
  8.         int i,j,n,m,x=0;
  9.         srand(time(NULL));
  10.         printf("Podaj rozmiar tablicy\n");
  11.         scanf("%d",&n);
  12.         int t[n];
  13.         printf("Podaj przedzial liczbowy wypelniajacy tablice\n");
  14.         scanf("%d",&m);
  15.         for(i=0; i<n; i++)
  16.         {
  17.             t[i]=rand()%m+1;
  18.             printf("t[%d]=%d\n",i,t[i]);
  19.         }
  20.         printf("\n");
  21.         for(i=0; i<m; i++)
  22.         {
  23.             for(j=0; j<n; j++)
  24.                 if (t[j]==i)
  25.                 {
  26.                     x++;
  27.                 }
  28.                
  29.                 if(x>0)
  30.                         printf("%d powtorzylo sie %d razy\n",t[i],x);
  31.                 x=0;
  32.         }
  33.         return 0;
  34.     }
  35.  
  36.