This commit is contained in:
Maryna Kravtsova 2020-11-22 13:28:03 +01:00
parent 9693133143
commit 87a8c88581

View File

@ -18,8 +18,8 @@ struct tree* read_tree(){
buffer[x-1]='\0'; buffer[x-1]='\0';
assert(r); assert(r);
if(buffer[0] != '\0'){
if(buffer[0] != '\0'){
struct tree* node = calloc(1,sizeof(struct tree)); struct tree* node = calloc(1,sizeof(struct tree));
memcpy(node->value, buffer,50); memcpy(node->value, buffer,50);
if(buffer[0] != '*'){ if(buffer[0] != '*'){
@ -30,10 +30,11 @@ struct tree* read_tree(){
node->right = read_tree(); node->right = read_tree();
} }
} }
//if(node->left != NULL && node->right != NULL){ //if(node->left != NULL && node->right != NULL){
return node; return node;
} }
// }
} }
struct tree* search(struct tree* this){ struct tree* search(struct tree* this){
@ -43,7 +44,7 @@ struct tree* search(struct tree* this){
int x = strlen(buffer); int x = strlen(buffer);
buffer[x-1]='\0'; buffer[x-1]='\0';
memcpy(buffer, this->value, 50); */ memcpy(buffer, this->value, 50); */
if(this != NULL){ if(this->left != NULL && this->right != NULL){
if(c == 'a'){ if(c == 'a'){
printf("%s\n", this->value); printf("%s\n", this->value);
this->left = search(this->left); this->left = search(this->left);