版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_26760433/article/details/84259523
在学习二叉树时,是不是感觉很抽象,其实我们可以写个程序将二叉树打印在屏幕上。
void print(BTree *root,int h)
{
if(root!=NULL)
{
print(root->rchild,h+1);
for(int i=0;i<h;i++)
cout<<" ";
cout<<root->value;
print(root->lchild,h+1);
}
cout<<endl;
}
int main()
{
print(root,0);
return 0;
}
输出效果:
治好了我多年的颈椎病。