Initializacia

This commit is contained in:
Kozar 2024-11-12 17:55:09 +00:00
parent ca43f2f982
commit 745926af82

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#define SIZE 100
@ -42,6 +41,7 @@ void run_tree(struct tree* tree) {
}
if (tree->value[0] == '*') {
// If it's an answer
printf("*%s\nKoniec\n", tree->value + 1);
return;
}
@ -65,21 +65,21 @@ void run_tree(struct tree* tree) {
}
void destroy_tree(struct tree* tree) {
if (tree->left != NULL) {
if (tree) {
destroy_tree(tree->left);
}
if (tree->right != NULL) {
destroy_tree(tree->right);
free(tree);
}
free(tree);
}
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) {
if (tree->left == NULL && tree->right == NULL) {
(*count)++;
} else {
count_items(tree->left, count);
count_items(tree->right, count);
}
}
}