56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
#include <assert.h>
|
||
|
|
||
|
#define SIZE 1000
|
||
|
|
||
|
struct node {
|
||
|
char question[SIZE];
|
||
|
struct node* left;
|
||
|
struct node* right;
|
||
|
};
|
||
|
|
||
|
//https://eli.thegreenplace.net/2009/11/23/visualizing-binary-trees-with-graphviz
|
||
|
|
||
|
void print_tree(struct node* tree,int offset){
|
||
|
for (int i = 0; i < offset; i++){
|
||
|
printf(" ");
|
||
|
}
|
||
|
printf("%s",tree->question);
|
||
|
if (tree->left){
|
||
|
print_tree(tree->left,offset +3);
|
||
|
print_tree(tree->right,offset +3);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
struct node* read_tree(){
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
void traverse(struct node* tree){
|
||
|
}
|
||
|
|
||
|
int count_fruit(struct node* tree){
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
void delete_tree(struct node* tree){
|
||
|
if (tree != NULL){
|
||
|
delete_tree(tree->left);
|
||
|
delete_tree(tree->right);
|
||
|
free(tree);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
printf("MUDrC to vie.\n");
|
||
|
struct node* tree = read_tree();
|
||
|
|
||
|
printf("Pozna %d druhov ovocia a zeleniny.\n",count_fruit(tree));
|
||
|
printf("Odpovedajte 'a' alebo 'n'\n");
|
||
|
traverse(tree);
|
||
|
delete_tree(tree);
|
||
|
}
|