Commit f5fba026 by Rudolf

Improve print tree graph

parent b66df99a
Showing with 7 additions and 10 deletions
......@@ -49,27 +49,24 @@ void print_tree(struct tree *parent)
{
int level = 1;
while (parent->left != NULL ) {
for (int i = 0; i < level; i++) {
if (parent->right) {
for (int i = 0; i < level; i++)
printf(" ");
}
if (parent->right)
print_char(parent->right->ch);
}
for (int i = 0; i < level-1; i++) {
printf(" ");
}
printf("o\n");
for (int i = 0; i < level; i++) {
if (parent->left && parent->left->ch != 0) {
for (int i = 0; i < level; i++)
printf(" ");
}
if (parent->left && parent->left->ch != 0)
print_char(parent->left->ch);
else
printf("o\n");
}
level += 2;
level += 1;
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