From aef5c8ee4d07f9e24cd6e0ba02943d993e30e4c8 Mon Sep 17 00:00:00 2001 From: ct453rn Date: Tue, 27 Feb 2024 15:10:58 +0100 Subject: [PATCH] test --- cv2/program.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cv2/program.c diff --git a/cv2/program.c b/cv2/program.c new file mode 100644 index 0000000..60c1027 --- /dev/null +++ b/cv2/program.c @@ -0,0 +1,37 @@ +#include +#include + +int main() { + int results[50], count = 0, num, maxPoharov = 0; + + while (scanf("%d", &num) == 1) { + if (num < 1 || num > 50) { + printf("Chyba: Neplatné číslo.\n"); + return 0; + } + if (count >= 50) { + break; + } + results[count++] = num; + } + + if (count == 0) { + printf("Chyba: Málo platných hodnôt.\n"); + return 0; + } + + for (int i = 0; i < count; i++) { + printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]); + if (results[i] > maxPoharov) { + maxPoharov = results[i]; + } + } + + for (int i = 0; i < count; i++) { + if (results[i] == maxPoharov) { + printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, maxPoharov); + } + } + + return 0; +}