Initializacia
This commit is contained in:
parent
0e5b2261b0
commit
e548847f2e
@ -31,6 +31,11 @@ struct tree* load_tree() {
|
|||||||
if (node->value[0] != '*') {
|
if (node->value[0] != '*') {
|
||||||
node->left = load_tree();
|
node->left = load_tree();
|
||||||
node->right = 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;
|
return node;
|
||||||
}
|
}
|
||||||
@ -41,7 +46,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -85,12 +89,12 @@ void count_items(struct tree* tree, int* count) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
struct tree* root = load_tree();
|
struct tree* root = load_tree();
|
||||||
printf("Expert z bufetu to vie.\n");
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
printf("Chybna databaza\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Expert z bufetu to vie.\n");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
count_items(root, &count);
|
count_items(root, &count);
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", count);
|
printf("Pozna %d druhov ovocia a zeleniny.\n", count);
|
||||||
|
Loading…
Reference in New Issue
Block a user