From 5d16981bdcae38af6b82437e5e94117b1056fb5a Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Tue, 27 Feb 2024 17:06:40 +0100 Subject: [PATCH] snad --- cv2/program.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cv2/program.c b/cv2/program.c index a76f333..1a077df 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -29,22 +29,21 @@ int main() { } int maxPoharov = pole[0]; - int vyhercovia[50]; - int pocetVyhercov = 0; + int pocetVyhercov = 1; for (int i = 1; i < pocetCisel; i++) { if (pole[i] > maxPoharov) { maxPoharov = pole[i]; - pocetVyhercov = 0; - vyhercovia[pocetVyhercov++] = i; + pocetVyhercov = 1; } else if (pole[i] == maxPoharov) { - vyhercovia[pocetVyhercov++] = i; + pocetVyhercov++; } } - - for (int i = 0; i < pocetVyhercov; i++) { - printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", vyhercovia[i] + 1, pole[vyhercovia[i]]); + for (int i = 0; i < pocetCisel; i++) { + if (pole[i] == maxPoharov) { + printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, pole[i]); + } } return 0;