pvjc25/du1/program.c

40 lines
844 B
C
Raw Normal View History

2025-02-27 17:19:02 +00:00
#include <stdio.h>
#include <stdlib.h>
#define VELKOST_POLA 50
int main() {
int results[VELKOST_POLA];
int count = 0;
2025-02-27 17:33:52 +00:00
int max_value = 0;
2025-02-27 17:19:02 +00:00
2025-02-27 17:33:52 +00:00
while (count < VELKOST_POLA) {
2025-02-27 17:19:02 +00:00
int temp;
if (scanf("%d", &temp) != 1 || temp < 1) {
break;
}
2025-02-27 17:33:52 +00:00
results[count] = temp;
2025-02-27 17:19:02 +00:00
if (temp > max_value) {
max_value = temp;
}
count++;
}
if (count == 0) {
2025-02-27 17:33:52 +00:00
printf("Chyba: Málo platných hodnôt.\n");
2025-02-27 17:19:02 +00:00
return 1;
}
for (int i = 0; i < count; i++) {
2025-02-27 17:33:52 +00:00
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
2025-02-27 17:19:02 +00:00
}
for (int i = 0; i < count; i++) {
if (results[i] == max_value) {
2025-02-27 17:33:52 +00:00
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
2025-02-27 17:19:02 +00:00
}
}
return 0;
}