From bdb448a1f50b6efc67614c56528b59b7feb6a578 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Mon, 11 Nov 2024 21:45:58 +0000 Subject: [PATCH] Update cv7/program.c --- cv7/program.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 40dcf06..8e6b204 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -25,16 +25,17 @@ struct tree* read_tree() assert(r); struct tree* node = (struct tree*)calloc(1,sizeof(struct tree)); memcpy(node->value,buffer,SIZE); - + + - + node->left=NULL; node->right=NULL; if(node->value[0]!='*') { - + node->left=read_tree(node->left); node->right=read_tree(node->right); @@ -47,7 +48,7 @@ void print_tree(struct tree* tree,int offset){ for (int i = 0; i < offset; i++){ printf("."); } - + if(tree) printf("%s",tree->value); if (tree->left){ @@ -65,8 +66,34 @@ int main(void) struct tree *tr; tr=read_tree(); - - print_tree(tr,3); + printf("\nExpert z bufetu to vie."); + printf("\nPozna 2 druhov ovocia a zeleniny."); + + struct tree *p=tr; + do + { + printf("%s",p->value); + if(p->value[0]=='*') + break; + printf("\nOdpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost."); + char t=fgetc(stdin); + if(t=='a') + p=p->left; + if(t=='n') + p=p->right; + + }while(1); + + + + + + //print_tree(tr,3); + printf("Koniec"); + + //printf("%s", tr->value); return 0; -} \ No newline at end of file +} + +