pvjc24/cv2/program.c

49 lines
1021 B
C
Raw Permalink Normal View History

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) {
2024-02-27 16:16:11 +00:00
break;
2024-02-27 14:05:17 +00:00
}
pole[pocetCisel] = cislo;
pocetCisel++;
}
if (pocetCisel == 0) {
printf("Chyba: Málo platných hodnôt.\n");
2024-02-27 16:21:51 +00:00
return 0;
2024-02-27 14:05:17 +00:00
}
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-29 10:48:22 +00:00
int pohare = pole[0];
2024-02-27 16:06:40 +00:00
int pocetVyhercov = 1;
2024-02-27 14:05:17 +00:00
for (int i = 1; i < pocetCisel; i++) {
2024-02-29 10:48:22 +00:00
if (pole[i] > pohare) {
pohare = pole[i];
2024-02-27 16:06:40 +00:00
pocetVyhercov = 1;
2024-02-29 10:48:22 +00:00
} else if (pole[i] == pohare) {
2024-02-27 16:06:40 +00:00
pocetVyhercov++;
2024-02-27 14:05:17 +00:00
}
}
2024-02-27 16:06:40 +00:00
for (int i = 0; i < pocetCisel; i++) {
2024-02-29 10:48:22 +00:00
if (pole[i] == pohare) {
2024-02-27 16:06:40 +00:00
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, pole[i]);
}
2024-02-27 15:26:04 +00:00
}
2024-02-27 14:05:17 +00:00
return 0;
2024-02-29 10:48:22 +00:00
}