Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define N 20
- int main()
- {
- int i;
- int tabA[N];
- int tabB[N];
- srand(time(NULL));
- int suma = 0;
- double srednia;
- int max;
- printf("Tablica A Tablica B\n");
- for(i=0; i <N; i++)
- {
- tabA[i] = rand() % 101;
- tabB[i] = rand() % 101;
- printf(" %d %d\n", tabA[i], tabB[i]);
- }
- //ŚREDNIA W TABLICY A
- for(i=0; i<N; i++)
- {
- suma=suma+tabA[i];
- }
- srednia = suma/N;
- printf("\nSrednia w tabA: %.3f", srednia);
- //NAJWIEKSZY ELEMENT W TABLICY B
- max = tabB[0];
- for(i=0; i<N; i++)
- {
- if(tabB[i] > max)
- max = tabB[i];
- }
- printf("\nMax w tabB: %d", max);
- printf("\nSrednia - max: %.3f", srednia - max);
- printf("\nMax - srednia: %.3f", max - srednia);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement