buffet
This commit is contained in:
parent
f6f5f0ce94
commit
cfb3f31df3
@ -34,20 +34,35 @@ struct tree* read_tree(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
struct tree* search(struct tree* this){
|
void search(struct tree* this){
|
||||||
|
|
||||||
int c = getchar();
|
|
||||||
if(this == NULL || this->value[0] == '*'){
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(c == 'a'){
|
char buffer[5];
|
||||||
|
memset(buffer,0,5);
|
||||||
|
char* r = fgets(buffer,5,stdin);
|
||||||
|
int x = strlen(buffer);
|
||||||
|
buffer[x-1]='\0';
|
||||||
|
|
||||||
|
if(this == NULL){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(buffer[0] == 'a'){
|
||||||
|
if(this->left->value[0] == '*'){
|
||||||
|
printf("%s\n", this->left->value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
printf("%s\n", this->left->value);
|
printf("%s\n", this->left->value);
|
||||||
return search(this->left);
|
search(this->left);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(c == 'n'){
|
|
||||||
|
else if(buffer[0] == 'n'){
|
||||||
|
if(this->right->value[0] == '*'){
|
||||||
|
printf("%s\n", this->right->value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
printf("%s\n", this->right->value);
|
printf("%s\n", this->right->value);
|
||||||
return search(this->right);
|
search(this->right);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +155,8 @@ 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);
|
//printf("%s\n", tree->value);
|
||||||
tree = search(tree);
|
search(tree);
|
||||||
destroy_tree(tree);
|
destroy_tree(tree);
|
||||||
printf("Koniec\n");
|
printf("Koniec\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user