From e548847f2e57f9dbb7d94949003d72b91b182bc8 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:15:40 +0000 Subject: [PATCH] Initializacia --- cv7/program.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e4fdfe0..0d71563 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -31,6 +31,11 @@ struct tree* load_tree() { if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); + } else if (node->left != NULL || node->right != NULL) { + printf("Expert z bufetu to vie.\n"); + printf("Chybna databaza\n"); + free(node); + return NULL; } return node; } @@ -41,7 +46,6 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - // If it's an answer printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -85,12 +89,12 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); - printf("Expert z bufetu to vie.\n"); if (!root) { - printf("Chybna databaza\n"); return 0; } + printf("Expert z bufetu to vie.\n"); + int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count);