pvjc25/du1/program.c

46 lines
1023 B
C
Raw Normal View History

2025-02-19 10:02:30 +00:00
#include <stdio.h>
#include <string.h>
#define VELKOST_POLA 52
int main() {
int pole[VELKOST_POLA];
memset(pole,0,VELKOST_POLA * sizeof(int));
int participant_count = 0;
for (int i = 0; i < VELKOST_POLA; ++i) {
int value = 0;
int r = scanf("%d", &value);
2025-02-19 10:13:24 +00:00
if(i == 0 && value < 0) {
printf("Chyba: Málo platných hodnôt.\n");
2025-02-19 10:14:49 +00:00
return 0;
2025-02-19 10:13:24 +00:00
}
2025-02-19 10:06:30 +00:00
if(r > 0 && value > 0) {
2025-02-19 10:02:30 +00:00
pole[i] = value;
participant_count++;
} else {
break;
}
}
int best_result = pole[0];
for (int i = 0; i < participant_count; ++i) {
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, pole[i]);
if(best_result < pole[i]) {
best_result = pole[i];
}
}
for (int i = 0; i < participant_count; ++i) {
if(pole[i] == best_result) {
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, best_result);
}
}
return 0;
}