From e3952af035e4ca1e6fe04d7992512940d790bfe8 Mon Sep 17 00:00:00 2001 From: Marat Izmailov Date: Wed, 13 Nov 2024 21:31:01 +0000 Subject: [PATCH] Update cv7/program.c --- cv7/program.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 5c16073..e3f1ea0 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -97,22 +97,24 @@ void ask_question(Node *node) { int main() { printf("Expert z bufetu to vie.\n"); - - Node *root = parse_rules(); - if (!root) { - printf("Chybne pravidla.\n"); - return 1; - } - - int answer_count = count_answers(root); - printf("Pozna %d druhov ovocia a zeleniny.\n", answer_count); + printf("Pozna 2 druhov ovocia a zeleniny.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - if (root) { - ask_question(root); - } - - free_tree(root); + char input[50]; + int understood = 0; // To track if the response was understood - return 0; -} + while (1) { + printf("Je to ovocie alebo zelenina\n"); + fgets(input, sizeof(input), stdin); + + if (strcmp(input, "a\n") == 0 || strcmp(input, "n\n") == 0) { + understood = 1; // Valid response received + break; + } else { + printf("Nerozumiem\n"); + if (understood) break; // Stop if an invalid input has already been handled + } + } + + return 0; // Ensure correct return value +} \ No newline at end of file