1sssaaaaaaa
This commit is contained in:
parent
0f5f86fa92
commit
82cc39f15b
@ -20,9 +20,8 @@ Node* read_tree() {
|
||||
n->left = NULL;
|
||||
n->right = NULL;
|
||||
|
||||
if (line[0] == '*') {
|
||||
if (line[0] == '*')
|
||||
return n;
|
||||
}
|
||||
|
||||
n->left = read_tree();
|
||||
n->right = read_tree();
|
||||
@ -43,46 +42,11 @@ void destroy_tree(Node* n) {
|
||||
}
|
||||
|
||||
void run(Node* n) {
|
||||
printf("Odpovedajte 'a' alebo 'n'\n");
|
||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||
|
||||
while (1) {
|
||||
printf("%s", n->text);
|
||||
|
||||
if (n->text[0] == '*') {
|
||||
printf("Koniec\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char c;
|
||||
if (scanf(" %c", &c) != 1) {
|
||||
printf("Nespravny vstup.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == 'a') n = n->left;
|
||||
else if (c == 'n') n = n->right;
|
||||
else {
|
||||
printf("Nespravny vstup.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
Node* root = read_tree();
|
||||
if (!root) {
|
||||
printf("Chyba: nepodarilo sa nacitat bazu pravidiel.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int items = count_leafs(root);
|
||||
|
||||
printf("MUDrC to vie.\n");
|
||||
printf("Pozna %d druhov ovocia a zeleniny.\n", items);
|
||||
|
||||
run(root);
|
||||
|
||||
destroy_tree(root);
|
||||
return 0;
|
||||
}
|
||||
printf("Kon
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user