From 63179fb08866c0b446109271230f6b43917f2f55 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Mon, 11 Nov 2024 22:28:18 +0000 Subject: [PATCH] Update cv7/program.c --- cv7/program.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 9cc872f..944cec8 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -4,7 +4,6 @@ #include #include - #define SIZE 200 struct tree @@ -21,14 +20,14 @@ struct tree* read_tree() char buffer[SIZE]; memset(buffer,0,SIZE); char* r = fgets(buffer,SIZE,stdin); - + assert(r); if(buffer[0]=='\n') return NULL; struct tree* node = (struct tree*)calloc(1,sizeof(struct tree)); memcpy(node->value,buffer,SIZE); - + node->left=NULL; node->right=NULL; @@ -80,27 +79,31 @@ int main(void) { printf("%s",p->value); if(p->value[0]=='*') - break; + break; + + do{ t=fgetc(stdin); if(t=='a') { - p=p->left; + p=p->left; break; } else if(t=='n') { - p=p->right; + p=p->right; break; } else if(t!='\n') { printf("Nerozumiem\n"); + t=44; + break; } - - }while(1); - + }while(1); + }while(t!=44); + printf("Koniec\n"); destroy_tree(tr); tr=NULL; - + return 0; }