commit
This commit is contained in:
parent
3439976ef7
commit
f30049329c
@ -25,10 +25,12 @@ struct Node* read_tree(void) {
|
|||||||
}
|
}
|
||||||
struct Node* node = calloc(1, sizeof(struct Node));
|
struct Node* node = calloc(1, sizeof(struct Node));
|
||||||
if (node == NULL) return NULL;
|
if (node == NULL) return NULL;
|
||||||
memcpy(node->value, buffer, SIZE);
|
strcpy(node->value, buffer);
|
||||||
|
|
||||||
if (buffer[0] != '*') {
|
if (buffer[0] != '*') {
|
||||||
node->left = read_tree();
|
node->left = read_tree();
|
||||||
|
node->right = read_tree();
|
||||||
|
|
||||||
if (node->left == NULL || node->right == NULL) {
|
if (node->left == NULL || node->right == NULL) {
|
||||||
destroy_tree(node);
|
destroy_tree(node);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -48,7 +50,7 @@ void run_system(struct Node* node) {
|
|||||||
printf("%s", node->value);
|
printf("%s", node->value);
|
||||||
|
|
||||||
if (node->left == NULL && node->right == NULL) {
|
if (node->left == NULL && node->right == NULL) {
|
||||||
printf("End\n");
|
printf("Koniec\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char answer[SIZE];
|
char answer[SIZE];
|
||||||
@ -71,18 +73,15 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char sep[SIZE];
|
char sep[SIZE];
|
||||||
if (fgets(sep, SIZE, stdin) == NULL || (sep[0] != '\n' && sep[0] != '\r')) {
|
fgets(sep, SIZE, stdin);
|
||||||
printf("Error: missing blank separator line.\n");
|
|
||||||
destroy_tree(root);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
int leaves = count_leaves(root);
|
int leaves = count_leaves(root);
|
||||||
printf("Expert z bufetu to vie.\n");
|
printf("Expert z bufetu to vie.\n");
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", leaves);
|
printf("Pozna %d druhov ovocia a zeleniny.\n", leaves);
|
||||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||||
|
|
||||||
run_system(root);
|
run_system(root);
|
||||||
destroy_tree(root);
|
|
||||||
|
|
||||||
|
destroy_tree(root);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user