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