refresh
This commit is contained in:
parent
292d614a73
commit
5a85ff5800
@ -13,9 +13,8 @@ typedef struct TreeNode {
|
|||||||
static TreeNode* read_tree_node() {
|
static TreeNode* read_tree_node() {
|
||||||
char buffer[MAXLINE];
|
char buffer[MAXLINE];
|
||||||
|
|
||||||
if (!fgets(buffer, sizeof(buffer), stdin)) {
|
if (!fgets(buffer, sizeof(buffer), stdin))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[0] == '\n' || buffer[0] == '\r')
|
if (buffer[0] == '\n' || buffer[0] == '\r')
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -54,9 +53,9 @@ static int count_leafs(TreeNode *root) {
|
|||||||
static int validate_tree(TreeNode *root) {
|
static int validate_tree(TreeNode *root) {
|
||||||
if (!root) return 0;
|
if (!root) return 0;
|
||||||
|
|
||||||
int is_answer = (root->text[0] == '*');
|
int is_leaf = (root->text[0] == '*');
|
||||||
|
|
||||||
if (is_answer) {
|
if (is_leaf) {
|
||||||
if (root->yes_branch || root->no_branch)
|
if (root->yes_branch || root->no_branch)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
@ -104,6 +103,18 @@ int main() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char chk[MAXLINE];
|
||||||
|
if (!fgets(chk, sizeof(chk), stdin)) {
|
||||||
|
printf("Chybna databaza\n");
|
||||||
|
free_tree(root);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(chk[0] == '\n' || chk[0] == '\r')) {
|
||||||
|
printf("Chybna databaza\n");
|
||||||
|
free_tree(root);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int total = count_leafs(root);
|
int total = count_leafs(root);
|
||||||
|
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", total);
|
printf("Pozna %d druhov ovocia a zeleniny.\n", total);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user