diff --git a/cv7/program.c b/cv7/program.c new file mode 100644 index 0000000..72a2de3 --- /dev/null +++ b/cv7/program.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#define SIZE 100 + +struct tree { + char* value; + struct tree* left; + struct tree* right; +}; + +struct tree* read_tree(){ + char buffer[SIZE]; + memset(buffer, 0, SIZE); + char* r = fgets(buffer, SIZE, stdin); + if(buffer[0] == '\n'){ + return NULL; + } + assert(r); + struct tree* node = calloc(1, sizeof(struct tree)); + node->value = malloc(strlen(buffer) + 1); + assert(node->value); + node->left = read_tree(); + node->right = read_tree(); + return node; +} + +void destroy_tree(struct tree* node) { + if (node == NULL) return; + destroy_tree(node->left); + destroy_tree(node->right); + free(node); +} + +int main(){ + struct tree* root = read_tree(); + read_tree(); + destroy_tree(root); + return 0; +} \ No newline at end of file diff --git a/cv7/program.exe b/cv7/program.exe new file mode 100644 index 0000000..e93aa93 Binary files /dev/null and b/cv7/program.exe differ