Initializacia
This commit is contained in:
parent
55853490b2
commit
36f9d01893
@ -29,9 +29,13 @@ struct tree* load_tree() {
|
|||||||
if (!node) {
|
if (!node) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (node->value[0] != '*') {
|
|
||||||
|
if (node->value[0] != '*') {
|
||||||
node->left = load_tree();
|
node->left = load_tree();
|
||||||
node->right = load_tree();
|
node->right = load_tree();
|
||||||
|
} else {
|
||||||
|
node->left = NULL;
|
||||||
|
node->right = NULL;
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@ -42,7 +46,7 @@ void run_tree(struct tree* tree) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tree->value[0] == '*') {
|
if (tree->value[0] == '*') {
|
||||||
printf("*%s\nKoniec\n", tree->value + 1);
|
printf("%s\nKoniec\n", tree->value + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +82,8 @@ void count_items(struct tree* tree, int* count) {
|
|||||||
if (tree->left == NULL && tree->right == NULL) {
|
if (tree->left == NULL && tree->right == NULL) {
|
||||||
(*count)++;
|
(*count)++;
|
||||||
} else {
|
} else {
|
||||||
count_items(tree->left, count);
|
if (tree->left) count_items(tree->left, count);
|
||||||
count_items(tree->right, count);
|
if (tree->right) count_items(tree->right, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user