This commit is contained in:
Maryna Kravtsova 2020-11-22 13:38:07 +01:00
parent 87a8c88581
commit 5f846d7771

View File

@ -46,19 +46,19 @@ struct tree* search(struct tree* this){
memcpy(buffer, this->value, 50); */ memcpy(buffer, this->value, 50); */
if(this->left != NULL && this->right != NULL){ if(this->left != NULL && this->right != NULL){
if(c == 'a'){ if(c == 'a'){
printf("%s\n", this->value); printf("%s\n", this->left);
this->left = search(this->left); this->left = search(this->left);
} }
else if(c == 'n'){ else if(c == 'n'){
printf("%s\n", this->value); printf("%s\n", this->right);
this->right = search(this->right); this->right = search(this->right);
} }
} }
else { else {
printf("%s\n", this->value); //printf("%s\n", this->value);
printf("Koniec\n"); printf("Koniec\n");
exit(0); return NULL;
} }
} }
@ -110,7 +110,7 @@ int main(){
printf("Expert z bufetu to vie.\n"); printf("Expert z bufetu to vie.\n");
printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Pozna %d druhov ovocia a zeleniny.\n", count);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
printf("%s\n", tree->value);
tree = search(tree); tree = search(tree);
destroy_tree(tree); destroy_tree(tree);
return 0; return 0;