From 04b91e7d5d490d39c9068e9ded01bd1841295669 Mon Sep 17 00:00:00 2001 From: Marat Izmailov Date: Wed, 13 Nov 2024 21:19:19 +0000 Subject: [PATCH] Update cv7/program.c --- cv7/program.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 5d62b4c..ab48413 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -38,7 +38,6 @@ Node* parse_rules() { int stack_top = -1; while (fgets(line, sizeof(line), stdin)) { - // Trim newline line[strcspn(line, "\n")] = 0; if (strlen(line) == 0) break; @@ -72,19 +71,17 @@ Node* parse_rules() { void ask_question(Node *node) { if (!node) return; if (node->yes == NULL && node->no == NULL) { + printf("*%s\n", node->content); printf("Koniec\n"); return; } printf("%s\n", node->content); - if (node->yes && node->yes->content[0] != '*') { - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - } char response; while (1) { response = getchar(); - getchar(); // To capture newline + getchar(); // Capture newline if (response == 'a' && node->yes) { ask_question(node->yes); break; @@ -109,9 +106,9 @@ int main() { int answer_count = count_answers(root); printf("Pozna %d druhov ovocia a zeleniny.\n", answer_count); + printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); if (root) { - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); ask_question(root); }