From 75cc8ff5541cd7b28f2d7653dfd5cd90f37e3b60 Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Sun, 9 Nov 2025 21:25:11 +0100 Subject: [PATCH] dndjna --- du6/program.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/du6/program.c b/du6/program.c index 83d9d6b..4a95b57 100644 --- a/du6/program.c +++ b/du6/program.c @@ -79,16 +79,12 @@ int count_leaves(struct tree* tree){ } } int count_non_leaves(struct tree* tree){ - if(tree == NULL || (tree->left == NULL && tree->right == NULL)){ + if(tree == NULL || ( tree->left== NULL && tree->right ==NULL)){ return 0; } - - return 1+ count_non_leaves(tree->left) + count_non_leaves(tree->right); - - + return 1 + count_non_leaves(tree->left) +count_non_leaves(tree->right); } - int main(void){ bool whitespace = false; @@ -96,6 +92,7 @@ int main(void){ char line[SIZE]; int numOfLeaves = count_leaves(tree); + int numOfNonLeaves = count_non_leaves(tree); char answer[SIZE]; while (fgets(line, sizeof(line), stdin)) { line[strcspn(line, "\n")] = '\0'; @@ -103,12 +100,10 @@ int main(void){ whitespace = true; break; } -} -int res = count_non_leaves(tree); -int res2 = numOfLeaves - res; +}; bool found = find_the_incorrect(tree); printf("Expert z bufetu to vie.\n"); - if(!tree || !whitespace || found || res2 < 1){ + if(!tree || !whitespace || found || strcmp(tree->value, "Je to ovocie alebo zelenina") != 0){ printf("Chybna databaza\n"); return 0; }