From 1e65c6ca68695d550929f8fb30a170b8d40e6837 Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Wed, 11 Nov 2020 01:00:01 +0100 Subject: [PATCH] zaciname --- cv6/a_station.c | 1 - cv8/main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 cv8/main.c diff --git a/cv6/a_station.c b/cv6/a_station.c index 5bf46ae..5d52a0c 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -11,7 +11,6 @@ struct station* create_station(){ return station; } void destroy_station(struct station* station){ - //struct car* del =prev; for(int i=0;i>station->track_count;i++){ struct car* prev = station->tracks[i]; while (prev!=NULL) diff --git a/cv8/main.c b/cv8/main.c new file mode 100644 index 0000000..d7cb4f5 --- /dev/null +++ b/cv8/main.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#define SIZE 100 + +struct tree { + char question[SIZE]; + //otazka ab. odpoved + char value[SIZE]; + // Odpoveď áno + struct tree* left; + // Odpoveď nie + struct tree* right; +}; + +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); + } +} + +void destroy_tree(struct tree* tree){ + free(tree); +} +struct tree* read_tree(){ + char buffer[SIZE]; + memset(buffer,0,SIZE); + char* r = fgets(buffer,SIZE,stdin); + assert(r); + struct tree* node = calloc(1,sizeof(struct tree)); + memcpy(node->value,buffer,SIZE); + // Ak je nacitany riadok listovy uzol ,tak netreba robit nic + // inak rekurzivne nacitanie laveho syna + // a rekurzivne nacitanie praveho syna + return node; +} +int main(){ +/*int counter = 0; +int si = 0; +struct tree* stack[SIZE]; +struct tree* this = tree; +while (si >= 0){ + assert(si < SIZE); + if (this->left){ + stack[si++] = this; + this = this->left; + continue; + } + counter += 1; + if (this->right){ + stack[si++] = this; + this = this->right; + continue; + } + si = si -1;*/ +return 0; +} \ No newline at end of file