2024-02-27 14:05:17 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int cislo;
|
|
|
|
int pole[50];
|
|
|
|
int pocetCisel = 0;
|
|
|
|
|
|
|
|
|
|
|
|
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++) {
|
2024-02-27 14:10:02 +00:00
|
|
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, pole[i]);
|
2024-02-27 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int vyhercaIndex = 0;
|
|
|
|
|
|
|
|
for (int i = 1; i < pocetCisel; i++) {
|
|
|
|
if (pole[i] > pole[vyhercaIndex]) {
|
|
|
|
vyhercaIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 14:11:14 +00:00
|
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", vyhercaIndex + 1, pole[vyhercaIndex]);
|
2024-02-27 14:05:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|