buffet
This commit is contained in:
parent
6e808e674b
commit
ca2b58c08e
@ -36,9 +36,13 @@ struct tree* read_tree(){
|
|||||||
return create_node();
|
return create_node();
|
||||||
}*/
|
}*/
|
||||||
if(buffer[0] != '*'){
|
if(buffer[0] != '*'){
|
||||||
|
if(node->left == NULL){
|
||||||
node->left = read_tree();
|
node->left = read_tree();
|
||||||
|
}
|
||||||
|
if(node->right == NULL){
|
||||||
node->right = read_tree();
|
node->right = read_tree();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*else if(string[0] == '*'){
|
/*else if(string[0] == '*'){
|
||||||
if(node->left == NULL){
|
if(node->left == NULL){
|
||||||
strcpy(node->value, string);
|
strcpy(node->value, string);
|
||||||
@ -47,9 +51,9 @@ struct tree* read_tree(){
|
|||||||
strcpy(node->value, string);
|
strcpy(node->value, string);
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
//if(node->left != NULL && node->right != NULL){
|
if(node->left != NULL && node->right != NULL){
|
||||||
return node;
|
return node;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_tree(struct tree* node, int offset){
|
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){
|
struct tree* search(struct tree* this, char answer){
|
||||||
if(this != NULL){
|
if(this != NULL){
|
||||||
if(answer == 'a'){
|
if(answer == 'a'){
|
||||||
|
printf("%s\n", this->value);
|
||||||
this->left = search(this, answer);
|
this->left = search(this, answer);
|
||||||
}
|
}
|
||||||
else if(answer == 'n'){
|
else if(answer == 'n'){
|
||||||
|
printf("%s\n", this->value);
|
||||||
this->right = search(this, answer);
|
this->right = search(this, answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -96,8 +101,7 @@ int count_l(struct tree* node){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return count_l(node->left);
|
return count_l(node->left) + count_l(node->right);
|
||||||
return count_l(node->right);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user