From ddfa83289992039aa30457c59ef14e879ddc398e Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 9 Nov 2024 21:50:22 +0000 Subject: [PATCH 1/4] Initializacia --- cv7/program.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 523b003..d43bea1 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -20,15 +20,16 @@ struct tree* read_tree(){ return node; } -struct tstruct tree* load_tree() { - struct tree* tree = read_tree(); - - tree->left = load_tree(); - tree->right = load_tree(); - - if (tree->value[0] == "*"){ - re +struct tree* load_tree() { + struct tree* node = read_tree(); + if (!node) { + return NULL; } + if (node->value[0] != '*') { + node->left = load_tree(); + node->right = load_tree(); + } + return node; } void print_tree(struct tree* tree,int offset){ @@ -61,11 +62,3 @@ void count_items(struct tree* tree, int* count){ } } -int main() { - printf("Constructing the tree:\n"); - struct tree* root = test(); - printf("The tree structure:\n"); - print_tree(root, 0); - - return 0; -} From 5f49f0f96749d23d988a9912c236f567415952ce Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:42:10 +0000 Subject: [PATCH 2/4] Initializacia --- cv7/program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cv7/program.c b/cv7/program.c index d43bea1..ffa74e2 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,7 @@ #include #include #include +#include #define SIZE 100 From ed485b28e3bb1e7a3dbb5416d4f493474b8a5bec Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:49:17 +0000 Subject: [PATCH 3/4] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index ffa74e2..ffd0948 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -56,7 +56,7 @@ void destroy_tree(struct tree* tree){ void count_items(struct tree* tree, int* count){ if(tree->left == NULL && tree->right == NULL){ - (*count)++ + (*count)++; }else{ count_items(tree->left, count); count_items(tree->right, count); From ad59e5210032a25adfed5e2650dded68861cb5a0 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:51:44 +0000 Subject: [PATCH 4/4] Initializacia --- cv7/program.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index ffd0948..b3e0900 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -33,14 +33,14 @@ struct tree* load_tree() { return node; } -void print_tree(struct tree* tree,int offset){ +void print_tree(struct tree* tree, int offset){ for (int i = 0; i < offset; i++){ printf(" "); } - printf("%s",tree->question); + printf("%s", tree->value); if (tree->left){ - print_tree(tree->left,offset +3); - print_tree(tree->right,offset +3); + print_tree(tree->left, offset + 3); + print_tree(tree->right, offset + 3); } }