This commit is contained in:
Maryna Kravtsova 2020-11-22 18:16:42 +01:00
parent c88245fafd
commit 73c5bf6d96

View File

@ -27,20 +27,20 @@ struct tree* read_tree(int* counter){
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);
*c += 1; *c += 1;
counter = &c; counter = c;
if(buffer[0] != '*'){ if(buffer[0] != '*'){
if(node->left == NULL){ if(node->left == NULL){
node->left = read_tree(); node->left = read_tree(counter);
} }
if(node->right == NULL){ if(node->right == NULL){
node->right = read_tree(); node->right = read_tree(counter);
} }
} }
if(node->left != NULL && node->right != NULL){ if(node->left != NULL && node->right != NULL){
*c -= 2; *c -= 2;
counter = &c; counter = c;
} }
if(c == 1){ if(*c == 1){
r = fgets(buffer,50, stdin); r = fgets(buffer,50, stdin);
//int x = strlen(buffer); //int x = strlen(buffer);
// buffer[x-1]='\0'; // buffer[x-1]='\0';