From d6fb14a74d36146d771ae5e05737ab9eeee2d0be Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Mon, 2 Mar 2020 19:29:12 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu2/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du2/program.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/du2/program.c b/du2/program.c index 3d0ab09..0584bad 100644 --- a/du2/program.c +++ b/du2/program.c @@ -5,7 +5,8 @@ int main() { int pole[VELKOST_POLA] = {0,0,0,0}; - int i = 0, max_hodnota = 0, quant_max = 0, value = 0, indexMan = 0; + int i = 0, max_hodnota = 0, value = 0; + while(value >= 0 || i <= 49 || value != EOF){ int r = scanf("%d",&value); @@ -15,10 +16,6 @@ int main() if(max_hodnota < value){ max_hodnota = value; - indexMan = i+1; - quant_max = 0; - } else if(max_hodnota == value){ - quant_max++; } if(r == 1){ @@ -31,7 +28,11 @@ int main() } } - printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", indexMan, max_hodnota); + for(;i >= 0; i--){ + if(pole[i] == max_hodnota){ + printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i+1, pole[i]); + } + } return 0; }