Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #define N 100
- int znajdz_max(int tab[], int ile_elementow, int *srednia) {
- int i, c, suma, max;
- max = tab[0];
- c = 0;
- suma = 0;
- for (i=0; i<ile_elementow; i++) {
- if (tab[i]>max) {
- max = tab[i];
- }
- if (tab[i] < 140) {
- suma = suma + tab[i];
- c++;
- }
- }
- suma = suma / c;
- *srednia = suma;
- return max;
- }
- int main(void) {
- int t[N];
- int i;
- int max, sr;
- srand(time(NULL));
- for (i=0; i<N; i++) {
- t[i]=rand()%8192;
- }
- max = znajdz_max(t, N, &sr);
- printf("maksymalna wartosc w tablicy = %d, srednia elementow ktore <140 = %d\n", max, sr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement