Initializacia
This commit is contained in:
parent
ca43f2f982
commit
745926af82
@ -1,6 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define SIZE 100
|
#define SIZE 100
|
||||||
@ -42,6 +41,7 @@ void run_tree(struct tree* tree) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tree->value[0] == '*') {
|
if (tree->value[0] == '*') {
|
||||||
|
// If it's an answer
|
||||||
printf("*%s\nKoniec\n", tree->value + 1);
|
printf("*%s\nKoniec\n", tree->value + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,21 +65,21 @@ void run_tree(struct tree* tree) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destroy_tree(struct tree* tree) {
|
void destroy_tree(struct tree* tree) {
|
||||||
if (tree->left != NULL) {
|
if (tree) {
|
||||||
destroy_tree(tree->left);
|
destroy_tree(tree->left);
|
||||||
}
|
|
||||||
if (tree->right != NULL) {
|
|
||||||
destroy_tree(tree->right);
|
destroy_tree(tree->right);
|
||||||
|
free(tree);
|
||||||
}
|
}
|
||||||
free(tree);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void count_items(struct tree* tree, int* count) {
|
void count_items(struct tree* tree, int* count) {
|
||||||
if (tree->left == NULL && tree->right == NULL) {
|
if (tree) {
|
||||||
(*count)++;
|
if (tree->left == NULL && tree->right == NULL) {
|
||||||
} else {
|
(*count)++;
|
||||||
count_items(tree->left, count);
|
} else {
|
||||||
count_items(tree->right, count);
|
count_items(tree->left, count);
|
||||||
|
count_items(tree->right, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user