diff --git a/du6/program.c b/du6/program.c index 57cf522..4ee51ec 100644 --- a/du6/program.c +++ b/du6/program.c @@ -78,6 +78,18 @@ int count_leaves(struct tree* tree){ } } +int count_non_leaves(struct tree* tree){ + int count = 0; + if(tree == NULL){ + return count; + } + if(tree->left && tree->right){ + return count + count_leaves(tree->left) + count_leaves(tree->right); + + } + return count+1; +} + int main(void){ bool whitespace = false; @@ -94,9 +106,11 @@ int main(void){ 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){ + if(!tree || !whitespace || found || res2 < 1){ printf("Chybna databaza\n"); return 0; }