Initializacia

This commit is contained in:
Kozar 2024-11-12 19:15:40 +00:00
parent 0e5b2261b0
commit e548847f2e

View File

@ -31,6 +31,11 @@ struct tree* load_tree() {
if (node->value[0] != '*') {
node->left = load_tree();
node->right = load_tree();
} else if (node->left != NULL || node->right != NULL) {
printf("Expert z bufetu to vie.\n");
printf("Chybna databaza\n");
free(node);
return NULL;
}
return node;
}
@ -41,7 +46,6 @@ void run_tree(struct tree* tree) {
}
if (tree->value[0] == '*') {
// If it's an answer
printf("*%s\nKoniec\n", tree->value + 1);
return;
}
@ -85,12 +89,12 @@ void count_items(struct tree* tree, int* count) {
int main() {
struct tree* root = load_tree();
printf("Expert z bufetu to vie.\n");
if (!root) {
printf("Chybna databaza\n");
return 0;
}
printf("Expert z bufetu to vie.\n");
int count = 0;
count_items(root, &count);
printf("Pozna %d druhov ovocia a zeleniny.\n", count);