Commit f5fba026 by Rudolf

Improve print tree graph

parent b66df99a
Showing with 9 additions and 12 deletions
...@@ -49,27 +49,24 @@ void print_tree(struct tree *parent) ...@@ -49,27 +49,24 @@ void print_tree(struct tree *parent)
{ {
int level = 1; int level = 1;
while (parent->left != NULL ) { while (parent->left != NULL ) {
for (int i = 0; i < level; i++) { if (parent->right) {
printf(" "); for (int i = 0; i < level; i++)
} printf(" ");
if (parent->right)
print_char(parent->right->ch); print_char(parent->right->ch);
}
for (int i = 0; i < level-1; i++) { for (int i = 0; i < level-1; i++) {
printf(" "); printf(" ");
} }
printf("o\n"); printf("o\n");
for (int i = 0; i < level; i++) { if (parent->left && parent->left->ch != 0) {
printf(" "); for (int i = 0; i < level; i++)
} printf(" ");
if (parent->left && parent->left->ch != 0)
print_char(parent->left->ch); print_char(parent->left->ch);
else }
printf("o\n");
level += 2; level += 1;
parent = parent->left; parent = parent->left;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment