diff --git a/cv2/program.c b/cv2/program.c index e69de29..fcfaba8 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -0,0 +1,44 @@ +#include + +int main() { + int cislo; + int pole[50]; + int pocetCisel = 0; + + printf("Zadajte maximalne 50 cisel:\n"); + + while (pocetCisel < 50) { + if (scanf("%d", &cislo) == EOF) { + break; + } + + if (cislo < 1) { + printf("Neplatne cislo zadane. Koniec nacitania.\n"); + return 1; + } + + pole[pocetCisel] = cislo; + pocetCisel++; + } + + if (pocetCisel == 0) { + printf("Chyba: Málo platných hodnôt.\n"); + return 1; + } + + for (int i = 0; i < pocetCisel; i++) { + printf("Sutaziaci %d vypil %d pohárov.\n", i + 1, pole[i]); + } + + int vyhercaIndex = 0; + + for (int i = 1; i < pocetCisel; i++) { + if (pole[i] > pole[vyhercaIndex]) { + vyhercaIndex = i; + } + } + + printf("Výherca je sútaziaci %d, ktory vypil %d poharov.\n", vyhercaIndex + 1, pole[vyhercaIndex]); + + return 0; +}