From 21898694d93bbf4157903ec992c5e9b4a31ac9f5 Mon Sep 17 00:00:00 2001 From: ak643du Date: Wed, 28 Feb 2024 13:23:11 +0100 Subject: [PATCH] G --- cv2/program.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/cv2/program.c b/cv2/program.c index e670a2a..ead1f43 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -3,16 +3,29 @@ #define FIELD_SIZE 52 int main(){ - int field[FIELD_SIZE] = {0,0,0,0}; - int count = 0; - int highest = 0; + int field[FIELD_SIZE] = {0}; // Inicializujte poľo na 0 + int count = 0; + int max_num = 0; + int input; - int r = scanf("%d", &field); - if (r == 1){ - printf("Súťažiaci č. %d vypil %d pohárov.\n",i+1,results[i]); - } - else { - printf("Načítanie sa nepodarilo. V premennej value ostala pôvodná hodnota. \n"); - } - + while (count < FIELD_SIZE) { + printf("Pocet poharov pre sutaziacieho c. %d: ", count + 1); + if (scanf("%d", &input) != 1) { + printf("Chyba pri nacitavani. Koniec vstupu.\n"); + break; + } + if (input < 0) { + printf("Ukoncenie zadavania.\n"); + break; + } + field[count] = input; + count++; + } + + printf("Vypisane hodnoty:\n"); + for (int i = 0; i < count; i++) { + printf("Sutaziaci c. %d vypil %d poharov.\n", i + 1, field[i]); + } + + return 0; }