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
|
|
|
}
|
|
|
|
|
2024-02-27 15:26:04 +00:00
|
|
|
int maxPoharov = pole[0];
|
|
|
|
int vyhercovia[50];
|
|
|
|
int pocetVyhercov = 0;
|
2024-02-27 14:05:17 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < pocetCisel; i++) {
|
2024-02-27 15:26:04 +00:00
|
|
|
if (pole[i] > maxPoharov) {
|
|
|
|
maxPoharov = pole[i];
|
|
|
|
pocetVyhercov = 0;
|
|
|
|
vyhercovia[pocetVyhercov++] = i;
|
|
|
|
} else if (pole[i] == maxPoharov) {
|
|
|
|
vyhercovia[pocetVyhercov++] = i;
|
2024-02-27 14:05:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 15:26:04 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < pocetVyhercov; i++) {
|
|
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", vyhercovia[i] + 1, pole[vyhercovia[i]]);
|
|
|
|
}
|
2024-02-27 14:05:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|