From dc8019ad2d18ad4455aae87b2ebffc24a99d7380 Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Sun, 9 Nov 2025 20:45:09 +0100 Subject: [PATCH] wejnrfnw --- du6/program.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/du6/program.c b/du6/program.c index 592d4a2..6bdae7b 100644 --- a/du6/program.c +++ b/du6/program.c @@ -22,16 +22,7 @@ void destroy_tree(struct tree* tree){ } free(tree); } -bool find_the_incorrect(struct tree* tree){ - if(tree == NULL){ - return false; - } - if(strcspn( tree->value, "*") != strlen(tree->value) || strcspn(tree->value, "?") != strlen(tree->value)){ - return true;} - return find_the_incorrect(tree->right) || find_the_incorrect(tree->left); - -} struct tree* read_tree(){ char buffer[SIZE]; memset(buffer,0,SIZE); @@ -52,6 +43,18 @@ struct tree* read_tree(){ node->right = read_tree(); return node; } +bool find_the_incorrect(struct tree* tree) { + if (tree == NULL) + return false; + + if (tree->value && + (strcspn(tree->value, "*") != strlen(tree->value) && + strcspn(tree->value, "?") != strlen(tree->value))) { + return true; + } + + return find_the_incorrect(tree->left) || find_the_incorrect(tree->right); +} void print_tree(struct tree* tree,int offset){ for (int i = 0; i < offset; i++){ printf(" "); @@ -78,8 +81,8 @@ int count_leaves(struct tree* tree){ int main(void){ bool whitespace = false; + struct tree* tree = read_tree(); - bool found = find_the_incorrect(tree); char line[SIZE]; int numOfLeaves = count_leaves(tree); @@ -91,7 +94,7 @@ int main(void){ break; } } - + bool found = find_the_incorrect(tree); printf("Expert z bufetu to vie.\n"); if(!tree || !whitespace || found){ printf("Chybna databaza\n"); @@ -134,5 +137,4 @@ int main(void){ } } destroy_tree(tree); -return 0;} - +return 0;} \ No newline at end of file