From 7e47b63aa39d76b8cc30cb57d7e68119a337e99b Mon Sep 17 00:00:00 2001 From: Denys Sanchuk Date: Tue, 25 Feb 2025 13:39:05 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20program.cv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- program.cv | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 program.cv diff --git a/program.cv b/program.cv new file mode 100644 index 0000000..b83e978 --- /dev/null +++ b/program.cv @@ -0,0 +1,37 @@ +#include +#include +#include + +#define MAX_CONTESTANTS 50 + +int main() { + int results[MAX_CONTESTANTS]; + int count = 0, value; + + while (count < MAX_CONTESTANTS) { + if (scanf("%d", &value) != 1 || value < 1) { + printf("Chyba: Málo platných hodnôt.\n"); + return 1; + } + results[count++] = value; + } + + for (int i = 0; i < count; i++) { + printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]); + } + + int max_value = results[0]; + for (int i = 1; i < count; i++) { + if (results[i] > max_value) { + max_value = 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]); + } + } + + return 0; +}