Update cv7/program.c
This commit is contained in:
parent
155f61e5e8
commit
39fde4afb0
@ -21,23 +21,22 @@ struct tree* read_tree()
|
||||
char buffer[SIZE];
|
||||
memset(buffer,0,SIZE);
|
||||
char* r = fgets(buffer,SIZE,stdin);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
return node;
|
||||
@ -67,8 +66,8 @@ int main(void)
|
||||
|
||||
tr=read_tree();
|
||||
|
||||
printf("\nExpert z bufetu to vie.");
|
||||
printf("\nPozna 2 druhov ovocia a zeleniny.");
|
||||
printf("Expert z bufetu to vie.\n");
|
||||
printf("Pozna 2 druhov ovocia a zeleniny.\n");
|
||||
|
||||
struct tree *p=tr;
|
||||
do
|
||||
@ -76,7 +75,7 @@ int main(void)
|
||||
printf("%s",p->value);
|
||||
if(p->value[0]=='*')
|
||||
break;
|
||||
printf("\nOdpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.");
|
||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||
char t=fgetc(stdin);
|
||||
if(t=='a')
|
||||
p=p->left;
|
||||
@ -89,10 +88,10 @@ int main(void)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
printf("Koniec");
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user