Initializacia

This commit is contained in:
Kozar 2024-11-10 15:38:32 +00:00
parent ea6d529fad
commit 9e1a60c36d

View File

@ -36,13 +36,14 @@ struct tree* load_tree() {
return node; return node;
} }
void print_tree(struct tree* tree, int offset) { void run_tree(struct tree* tree) {
if (!tree) { if (!tree) {
return; return;
} }
if (tree->value[0] == '*') { if (tree->value[0] == '*') {
printf("Expert z bufetu to vie.\n%s\nKoniec\n", tree->value + 1); printf("Expert z bufetu to vie.\n%s\nKoniec\n", tree->value + 1);
printf("*");
return; return;
} }
@ -55,9 +56,9 @@ void print_tree(struct tree* tree, int offset) {
} }
if (response == 'a') { if (response == 'a') {
print_tree(tree->left, offset + 3); run_tree(tree->left);
} else { } else {
print_tree(tree->right, offset + 3); run_tree(tree->right);
} }
} }
@ -92,7 +93,7 @@ int main() {
printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Pozna %d druhov ovocia a zeleniny.\n", count);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
print_tree(root, 0); run_tree(root);
destroy_tree(root); destroy_tree(root);
return 0; return 0;