From c8bc3e152b678198f7665af595e6089fcfb24b32 Mon Sep 17 00:00:00 2001 From: ak643du Date: Wed, 28 Feb 2024 13:29:57 +0100 Subject: [PATCH] G --- cv2/program.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cv2/program.c b/cv2/program.c index 5b67c99..2be7056 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -3,21 +3,22 @@ #define FIELD_SIZE 52 int main(){ - int field[FIELD_SIZE] = {0}; // Inicializujte poľo na 0 + int field[FIELD_SIZE] = {0}; int count = 0; int max_num = 0; int input; while (count < FIELD_SIZE) { - if (input < 0) { - printf("Ukoncenie zadavania.\n"); + if (scanf("%d", &input) != 1) { + break; + } + if (input < 0) { break; } field[count] = input; count++; } - printf("Vypisane hodnoty:\n"); for (int i = 0; i < count; i++) { printf("Sutaziaci č. %d vypil %d pohárov.\n", i + 1, field[i]); }