50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
#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) {
|
|
break;
|
|
}
|
|
|
|
pole[pocetCisel] = cislo;
|
|
pocetCisel++;
|
|
}
|
|
|
|
if (pocetCisel == 0) {
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 0;
|
|
}
|
|
|
|
for (int i = 0; i < pocetCisel; i++) {
|
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, pole[i]);
|
|
}
|
|
|
|
int maxPoharov = pole[0];
|
|
int pocetVyhercov = 1;
|
|
|
|
for (int i = 1; i < pocetCisel; i++) {
|
|
if (pole[i] > maxPoharov) {
|
|
maxPoharov = pole[i];
|
|
pocetVyhercov = 1;
|
|
} else if (pole[i] == maxPoharov) {
|
|
pocetVyhercov++;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < pocetCisel; i++) {
|
|
if (pole[i] == maxPoharov) {
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, pole[i]);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|