Initializacia
This commit is contained in:
parent
36f9d01893
commit
8d07713b65
@ -1,6 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SIZE 100
|
||||
@ -33,12 +32,8 @@ struct tree* load_tree() {
|
||||
if (node->value[0] != '*') {
|
||||
node->left = load_tree();
|
||||
node->right = load_tree();
|
||||
} else {
|
||||
node->left = NULL;
|
||||
node->right = NULL;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
void run_tree(struct tree* tree) {
|
||||
if (!tree) {
|
||||
@ -79,7 +74,9 @@ void destroy_tree(struct tree* tree) {
|
||||
}
|
||||
|
||||
void count_items(struct tree* tree, int* count) {
|
||||
if (tree->left == NULL && tree->right == NULL) {
|
||||
if (!tree) return;
|
||||
|
||||
if (tree->value[0] == '*') {
|
||||
(*count)++;
|
||||
} else {
|
||||
if (tree->left) count_items(tree->left, count);
|
||||
@ -90,6 +87,7 @@ void count_items(struct tree* tree, int* count) {
|
||||
int main() {
|
||||
struct tree* root = load_tree();
|
||||
printf("Expert z bufetu to vie.\n");
|
||||
|
||||
if (!root) {
|
||||
printf("Chybna databaza\n");
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user