Advertisement
lukasd

2 zadanie z 8 zestawu

Dec 15th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. float takio(int a[])
  2. {
  3.     float srednia;
  4.     float suma=0;
  5.     float najblizszy=a[0];
  6.     for (int i = 0; i < 20; i++)
  7.     {
  8.         a[i] = rand() % 90 + 10;
  9.             suma = suma + a[i];
  10.     }
  11.     srednia = suma / 20;
  12.     for (int k = 1; k < 20; k++)
  13.     {
  14.         if (abs((srednia - najblizszy)) > abs((srednia - a[k])))
  15.         {
  16.             najblizszy = a[k];
  17.         }
  18.     }
  19.     return najblizszy;
  20. }
  21.    
  22.  
  23. void kolos1()
  24. {
  25.     int a[20];
  26.     printf("%f", takio(a));
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement