Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. int zad4(float sr, int max, int min )
  2. {
  3. int x, i, ile;
  4. i = 0;
  5. printf("ile: ");
  6. scanf("%d", &ile);
  7. int tab[ile];
  8. do
  9. {
  10. printf("podaj liczbe: ");
  11. scanf("%d", &tab[i]);
  12. sr+=tab[i];
  13. i++;
  14. }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.
  15. sr/=ile;
  16. printf("%.2f", sr);
  17. max = tab[0];
  18. min = tab[0];
  19. for(i = 0 ; i < ile ; i++)
  20. {
  21. printf("\n %d", tab[i]);
  22. if (tab[i]>max) max=tab[i];
  23. if (tab[i]<min) min=tab[i];
  24. }
  25. printf("\nmax %d", max);
  26. printf("\nmin %d", min);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement