This commit is contained in:
Maryna Kravtsova 2020-11-22 11:58:56 +01:00
parent 5c6d8f47dc
commit 2469d21681

View File

@ -51,32 +51,27 @@ void print_tree(struct tree* node, int offset){
struct tree* search(struct tree* this){
char buffer[5];
memset(buffer,0,5);
char* r = fgets(buffer,5,stdin);
int x = strlen(buffer);
buffer[x-1]='\0';
if(buffer[0] != 'a' && buffer[0] != 'n'){
printf("Chyba\n");
exit(0);
}
if(this != NULL){
/*if(count ==){
printf("%s\n", this->value);
}*/
/*if(buffer[0] != 'a' || buffer[0] != 'n'){
return NULL;
}*/
if(buffer[0] == 'a'){
printf("%s\n", this->value);
this->left = search(this);
this = search(this->left);
}
else if(buffer[0] == 'n'){
printf("%s\n", this->value);
this->right = search(this);
this = search(this->right);
}
}
else{
printf("Koniec\n");
exit(0);
}
return this;
}
void destroy_tree(struct tree* root){
@ -126,12 +121,14 @@ int main(){
printf("Expert z bufetu to vie\n");
printf("Pozna %d druhov ovocia a zeleniny\n", count);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
printf("%s\n", tree->value);
//printf("%s\n", tree->value);
//int all = count_all(tree);
tree = search(tree);
//print_tree(tree, 3);
//display(tree);
destroy_tree(tree);
//destroy_tree(tree);
return 0;
}