du6.3
This commit is contained in:
parent
cf3e69ac7c
commit
31386185a1
@ -39,13 +39,13 @@ Tree* read_tree() {
|
||||
void destroy_tree(Tree* t){
|
||||
if(!t) return;
|
||||
destroy_tree(t->left);
|
||||
destry_tree(t->right);
|
||||
destroy_tree(t->right);
|
||||
free(t);
|
||||
}
|
||||
int count_leaves(Tree* t){
|
||||
if(!t) return 0;
|
||||
if(!t->left && !t->right) return 1;
|
||||
return count_leaves(5->left) + count_leaves(t->right);
|
||||
return count_leaves(t->left) + count_leaves(t->right);
|
||||
|
||||
}
|
||||
void run_system(Tree* t) {
|
||||
@ -67,7 +67,7 @@ void run_system(Tree* t) {
|
||||
return;
|
||||
}
|
||||
|
||||
trim_newline(ans);
|
||||
trim(ans);
|
||||
|
||||
if (strcmp(ans, "a") == 0)
|
||||
run_system(t->left);
|
||||
@ -91,8 +91,8 @@ int main() {
|
||||
printf("Pozna %d druhov ovocia a zeleniny.\n", count);
|
||||
|
||||
// overenie prázdneho riadku medzi databázou a vstupom používateľa
|
||||
char empty[SIZE];
|
||||
if (!fgets(empty, SIZE, stdin) || strcmp(empty, "\n") != 0) {
|
||||
char empty[256];
|
||||
if (!fgets(empty, 256, stdin) || strcmp(empty, "\n") != 0) {
|
||||
printf("Chyba: chýba prázdny riadok medzi databázou a vstupom.\n");
|
||||
destroy_tree(root);
|
||||
return 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user