Update 'cv8/program.c'

This commit is contained in:
Anzhelika Nikolaieva 2023-11-24 22:14:16 +00:00
parent 1f68678676
commit b488232679

View File

@ -3,7 +3,6 @@
#include <string.h>
#include <assert.h>
#define SIZE 256
struct tree {
@ -12,7 +11,6 @@ struct tree {
struct tree* right;
};
struct tree* read_tree(int* counter);
void destroy_tree(struct tree* tree);
void print_tree(struct tree* tree, int offset);
@ -43,14 +41,14 @@ struct tree* read_tree(int* counter) {
void destroy_tree(struct tree* tree) {
if (tree) {
destroy_tree(tree->left);
destroy_tree(tree->right);
destroy_tree(tree->right);
free(tree);
}
}
void print_tree(struct tree* tree, int offset) {
for (int i = 0; i < offset; i++) {
//printf(" ");
printf(" ");
}
printf("%s", tree->v);
if (tree->left) {
@ -96,17 +94,17 @@ void knowledge_system(struct tree* node) {
return;
}
printf("%s", node->v);
if (node->left == NULL && node->right == NULL) {
printf("%s", node->v);
printf("Koniec\n");
return;
}
printf("%s", node->v);
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
char response;
do {
printf("%s", node->v);
scanf(" %c", &response);
if (response != 'a' && response != 'n') {
printf("Nespravny vstup\n");
@ -123,7 +121,7 @@ void knowledge_system(struct tree* node) {
int main() {
printf("Expert z bufetu to vie.\n");
int counter = 0;
struct tree* root = read_tree(&counter);