Advertisement
danql45

Untitled

Dec 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7.     float tab[20];
  8.     float min, max, zakres1,zakres2,los,sumtab=0;
  9.     float srednia,c=1;
  10.     printf("Zakres MIN: ");
  11.     scanf("%f",&min);
  12.     printf("Zakres MAX: ");
  13.     scanf("%f",&max);
  14.     zakres1=((max-min)+c);
  15.     zakres2=zakres1+min;
  16.     printf("Zakres1 = %f\n",zakres1);
  17.     printf("Zakres2 = %f\n",zakres2);
  18.     printf("Tablica: ");
  19.     srand(time(NULL));
  20.     for (int i=0;i<20;i++)
  21.     {
  22.         los=rand()%zakres1+min;
  23.         tab[i]=los;
  24.         printf("%f, ",tab[i]);
  25.  
  26.         if(i<20)
  27.         {
  28.             sumtab+=los;
  29.         }
  30.     }
  31.     srednia=sumtab/20;
  32.     printf("\n\n");
  33.     printf("Srednia arytmetyczna wyrazow w tablicy: %f",srednia);
  34.  
  35.        
  36.  
  37.  
  38.     printf("\n\n");
  39.     printf("Suma wyrazow w tablicy: %f",sumtab);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement