From a480aa16fea7258d920254fa94aaa6b0535029f8 Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Sun, 9 Nov 2025 21:12:46 +0100 Subject: [PATCH] wejfw --- du6/program.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/du6/program.c b/du6/program.c index 4ee51ec..83d9d6b 100644 --- a/du6/program.c +++ b/du6/program.c @@ -79,15 +79,13 @@ int count_leaves(struct tree* tree){ } } int count_non_leaves(struct tree* tree){ - int count = 0; - if(tree == NULL){ - return count; + if(tree == NULL || (tree->left == NULL && tree->right == NULL)){ + return 0; } - if(tree->left && tree->right){ - return count + count_leaves(tree->left) + count_leaves(tree->right); - } - return count+1; + return 1+ count_non_leaves(tree->left) + count_non_leaves(tree->right); + + }