Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int zad4(float sr, int max, int min )
- {
- int x, i, ile;
- i = 0;
- printf("ile: ");
- scanf("%d", &ile);
- int tab[ile];
- do
- {
- printf("podaj liczbe: ");
- scanf("%d", &tab[i]);
- sr+=tab[i];
- i++;
- }while((i<ile) && (tab[i]!=0)); // tu jest blad - teraz wysypuje sie przy ilosci danych 4++. Jak dam || to wyswietla mi wiecej "podaj liczbe" niz podam ilosc. Ale i tak czyta tyle ile chce. Np podam: "ile : 5" to wyswietla "podaj liczbe: " 8x, mimo ze tablica wypelnia sie 5 elementami.
- sr/=ile;
- printf("%.2f", sr);
- max = tab[0];
- min = tab[0];
- for(i = 0 ; i < ile ; i++)
- {
- printf("\n %d", tab[i]);
- if (tab[i]>max) max=tab[i];
- if (tab[i]<min) min=tab[i];
- }
- printf("\nmax %d", max);
- printf("\nmin %d", min);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement