Update cv7/program.c

This commit is contained in:
Yurii Yakovenko 2024-11-11 22:28:18 +00:00
parent 8b4c6f2707
commit 63179fb088

View File

@ -4,7 +4,6 @@
#include <assert.h>
#include <string.h>
#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;
}