Dufam
This commit is contained in:
parent
fe27e48fa0
commit
98e27550b1
@ -13,12 +13,20 @@ struct tree* read_tree();
|
|||||||
void system_execute(struct tree* root);
|
void system_execute(struct tree* root);
|
||||||
int get_input(char *string);
|
int get_input(char *string);
|
||||||
int type_count(struct tree* root);
|
int type_count(struct tree* root);
|
||||||
|
void destroy(struct tree* root);
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
struct tree* root = NULL;
|
struct tree* root = NULL;
|
||||||
root = read_tree();
|
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.");
|
puts("Expert z bufetu to vie.");
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n",type_count(root));
|
printf("Pozna %d druhov ovocia a zeleniny.\n",type_count(root));
|
||||||
@ -29,6 +37,8 @@ int main(){
|
|||||||
getchar();
|
getchar();
|
||||||
puts("Koniec");
|
puts("Koniec");
|
||||||
|
|
||||||
|
destroy(root);
|
||||||
|
free(buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,3 +113,12 @@ int type_count(struct tree* root){//https://www.youtube.com/watch?v=Uze4GgUj3Fs&
|
|||||||
int count= type_count(root->left)+type_count(root->right);
|
int count= type_count(root->left)+type_count(root->right);
|
||||||
return count;
|
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