This commit is contained in:
Maryna Kravtsova 2020-11-22 13:02:08 +01:00
parent 555c9e23da
commit 68027a623e

View File

@ -18,11 +18,15 @@ struct tree* read_tree(){
buffer[x-1]='\0';
assert(r);
if(buffer[0] == '\0'){
return NULL;
}
struct tree* node = calloc(1,sizeof(struct tree));
if(buffer[0] == '\0'){
/*if(buffer[0] == '\0'){
return node;
}
}*/
memcpy(node->value, buffer,50);
if(buffer[0] != '*'){
if(node->left == NULL){
@ -38,12 +42,11 @@ struct tree* read_tree(){
}
struct tree* search(struct tree* this){
char question[30] = "Je to ovocie alebo zelenina";
/*char question[30] = "Je to ovocie alebo zelenina";
if(strcmp(this->value,question) == 0){
printf("%s\n", this->value);
this = search(this->left);
}
this = search(this);
}*/
char c = getchar();
char buffer[50];
buffer[strlen(buffer)-1]='\0';
@ -53,11 +56,11 @@ struct tree* search(struct tree* this){
if(buffer[0] != '*'){
if(c == 'a'){
printf("%s\n", this->value);
this->left = search(this->left);
this = search(this->left);
}
else if(c == 'n'){
printf("%s\n", this->value);
this->right = search(this->right);
this = search(this->right);
}
}