This commit is contained in:
Maryna Kravtsova 2020-11-21 16:59:00 +01:00
parent 6e808e674b
commit ca2b58c08e

View File

@ -36,9 +36,13 @@ struct tree* read_tree(){
return create_node();
}*/
if(buffer[0] != '*'){
if(node->left == NULL){
node->left = read_tree();
}
if(node->right == NULL){
node->right = read_tree();
}
}
/*else if(string[0] == '*'){
if(node->left == NULL){
strcpy(node->value, string);
@ -47,9 +51,9 @@ struct tree* read_tree(){
strcpy(node->value, string);
}
}*/
//if(node->left != NULL && node->right != NULL){
if(node->left != NULL && node->right != NULL){
return node;
//}
}
}
void print_tree(struct tree* node, int offset){
@ -67,12 +71,13 @@ void print_tree(struct tree* node, int offset){
struct tree* search(struct tree* this, char answer){
if(this != NULL){
if(answer == 'a'){
printf("%s\n", this->value);
this->left = search(this, answer);
}
else if(answer == 'n'){
printf("%s\n", this->value);
this->right = search(this, answer);
}
}
else{
exit(0);
@ -96,8 +101,7 @@ int count_l(struct tree* node){
return 1;
}
else{
return count_l(node->left);
return count_l(node->right);
return count_l(node->left) + count_l(node->right);
}
}