This commit is contained in:
Maksym Malko 2020-11-27 12:56:54 +01:00
parent fe27e48fa0
commit 98e27550b1
2 changed files with 20 additions and 1 deletions

BIN
cv8/a.out

Binary file not shown.

View File

@ -13,12 +13,20 @@ struct tree* read_tree();
void system_execute(struct tree* root);
int get_input(char *string);
int type_count(struct tree* root);
void destroy(struct tree* root);
int main(){
struct tree* root = NULL;
root = read_tree();
getchar();
char *buffer = calloc(SIZE,sizeof(char));
int flag = get_input(buffer);
if(flag==-1){
puts("Expert z bufetu to vie.");
puts("Chybna databaza");
exit(0);
}
puts("Expert z bufetu to vie.");
printf("Pozna %d druhov ovocia a zeleniny.\n",type_count(root));
@ -29,6 +37,8 @@ int main(){
getchar();
puts("Koniec");
destroy(root);
free(buffer);
return 0;
}
@ -102,4 +112,13 @@ int type_count(struct tree* root){//https://www.youtube.com/watch?v=Uze4GgUj3Fs&
}
int count= type_count(root->left)+type_count(root->right);
return count;
}
void destroy(struct tree* root){
if (root == NULL){
return;
}
destroy(root->left);
destroy(root->right);
free(root);
}