Dufam
This commit is contained in:
parent
fe27e48fa0
commit
98e27550b1
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user