From 2d1862f3ca6abcc9a67d7746c7857fa2acb20c0f Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Mon, 11 Nov 2024 22:51:03 +0000 Subject: [PATCH] Update cv7/program.c --- cv7/program.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 362748c..13dc55d 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -54,6 +54,22 @@ void print_tree(struct tree* tree,int offset){ } } +int kkk(struct tree* tree, int x) +{ + if (!tree) + { + return x; + } + + x += (tree->value[0] == '*'); + + x = kkk(tree->left, x); + x = kkk(tree->right, x); + + return x; +} + + void destroy_tree(struct tree* tree){ if(tree==NULL) return; @@ -68,10 +84,13 @@ int main(void) struct tree *tr; tr=read_tree(); + int kk; char t; + kk=kkk(tr,0); + printf("Expert z bufetu to vie.\n"); - printf("Pozna 2 druhov ovocia a zeleniny.\n"); + printf("Pozna %d druhov ovocia a zeleniny.\n", kk); struct tree *p=tr; printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); @@ -115,4 +134,3 @@ int main(void) } -