Update cv7/program.c

This commit is contained in:
Yurii Yakovenko 2024-11-11 22:19:11 +00:00
parent bf7202663e
commit 64bfb1ea96

View File

@ -4,6 +4,7 @@
#include <assert.h>
#include <string.h>
#define SIZE 200
struct tree
@ -11,6 +12,7 @@ struct tree
char value[SIZE];
struct tree *left, *right;
};
@ -20,7 +22,6 @@ struct tree* read_tree()
memset(buffer,0,SIZE);
char* r = fgets(buffer,SIZE,stdin);
assert(r);
if(buffer[0]=='\n')
@ -33,9 +34,7 @@ struct tree* read_tree()
if(node->value[0]!='*')
{
node->left=read_tree(node->left);
node->right=read_tree(node->right);
}
return node;
@ -46,7 +45,6 @@ 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){
@ -83,14 +81,19 @@ int main(void)
printf("%s",p->value);
if(p->value[0]=='*')
break;
do
t=fgetc(stdin);
if(t=='a')
{
t=fgetc(stdin);
if(t=='a')
{p=p->left; break;}
if(t=='n')
{p=p->right; break;}
}while(1);
p=p->left; break;
}
else if(t=='n')
{
p=p->right; break;
}
else
{
printf("Nerozumiem\n");
}
}while(1);
@ -100,3 +103,5 @@ int main(void)
return 0;
}