From 745926af828ac87df09d27ca3526af94d71b2f8f Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 17:55:09 +0000 Subject: [PATCH] Initializacia --- cv7/program.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e7ae045..e4fdfe0 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SIZE 100 @@ -42,6 +41,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { + // If it's an answer printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -65,21 +65,21 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (tree->left != NULL) { + if (tree) { destroy_tree(tree->left); - } - if (tree->right != NULL) { destroy_tree(tree->right); + free(tree); } - free(tree); } void count_items(struct tree* tree, int* count) { - if (tree->left == NULL && tree->right == NULL) { - (*count)++; - } else { - count_items(tree->left, count); - count_items(tree->right, count); + if (tree) { + if (tree->left == NULL && tree->right == NULL) { + (*count)++; + } else { + count_items(tree->left, count); + count_items(tree->right, count); + } } }