buffet
This commit is contained in:
parent
6e808e674b
commit
ca2b58c08e
@ -36,8 +36,12 @@ struct tree* read_tree(){
|
||||
return create_node();
|
||||
}*/
|
||||
if(buffer[0] != '*'){
|
||||
node->left = read_tree();
|
||||
node->right = read_tree();
|
||||
if(node->left == NULL){
|
||||
node->left = read_tree();
|
||||
}
|
||||
if(node->right == NULL){
|
||||
node->right = read_tree();
|
||||
}
|
||||
}
|
||||
/*else if(string[0] == '*'){
|
||||
if(node->left == NULL){
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user