建立二叉树,打印二叉树结构,并对其进行遍历(先序,中序,后序),打印输出遍历结果
测试数据ABC**DE*G**F*** 其中*表示空格字符
则输出结果为 先序ABCDEGF
中序CBEGDFA
后序CGBFDBA
还要打印输出该二叉树
有哪位大佬会写的吗?
程序代码:struct tree{
int Element;
struct tree *Left;
struct tree *Right;
}*tree;
void
qianxu( tree Root )//中序,后序,也就改改printf()函数的位置。而打印树,也就将printf()函数改成打印函数。
{
if( NULL == Root )
return ;
printrf( "%d ",Root->Element );
qianxu( Root->Left );
qianxu( Root->Right );
}
