Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define N 20
  5.  
  6. int main()
  7. {
  8.     int i;
  9.     int tabA[N];
  10.     int tabB[N];
  11.     srand(time(NULL));
  12.     int suma = 0;
  13.     double srednia;
  14.     int max;
  15.  
  16.     printf("Tablica A     Tablica B\n");
  17.  
  18.     for(i=0; i <N; i++)
  19.     {
  20.         tabA[i] = rand() % 101;
  21.         tabB[i] = rand() % 101;
  22.         printf("    %d            %d\n", tabA[i], tabB[i]);
  23.     }
  24.  
  25.     //ŚREDNIA W TABLICY A
  26.     for(i=0; i<N; i++)
  27.     {
  28.         suma=suma+tabA[i];
  29.     }
  30.     srednia = suma/N;
  31.     printf("\nSrednia w tabA: %.3f", srednia);
  32.  
  33.     //NAJWIEKSZY ELEMENT W TABLICY B
  34.     max = tabB[0];
  35.     for(i=0; i<N; i++)
  36.     {
  37.         if(tabB[i] > max)
  38.             max = tabB[i];
  39.     }
  40.     printf("\nMax w tabB: %d", max);
  41.  
  42.     printf("\nSrednia - max: %.3f", srednia - max);
  43.     printf("\nMax - srednia: %.3f", max - srednia);
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement