This commit is contained in:
Denis Landa 2025-02-27 18:33:52 +01:00
parent c3505122a9
commit 06e1138f69

View File

@ -1,45 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VELKOST_POLA 50
int main() {
int results[VELKOST_POLA];
memset(results, 0, VELKOST_POLA * sizeof(int));
int max_value = 0;
int count = 0;
int max_value = 0;
printf("Zadajte výsledky súťažiacich (max %d, ukončite nečíselným vstupom alebo EOF):\n", VELKOST_POLA);
for (int i = 0; i < VELKOST_POLA; i++) {
while (count < VELKOST_POLA) {
int temp;
if (scanf("%d", &temp) != 1 || temp < 1) {
break;
}
results[i] = temp;
results[count] = temp;
if (temp > max_value) {
max_value = temp;
}
count++;
if (getchar() != '_') {
break;
}
}
if (count == 0) {
printf("Chyba:_Málo_platných_hodnôt.\n");
printf("Chyba: Málo platných hodnôt.\n");
return 1;
}
for (int i = 0; i < count; i++) {
printf("Súťažiaci_č._%d_vypil_%d_pohárov.\n", i + 1, results[i]);
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
}
for (int i = 0; i < count; i++) {
if (results[i] == max_value) {
printf("Výherca_je_súťažiaci_%d_ktorý_vypil_%d_pohárov.\n", i + 1, results[i]);
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
}
}