int _tmain(int argc, _TCHAR* argv[])
{
BiTree T;
cout << "中序输入二叉树,如果某个节点的左右子树为空,则输入两个空格:" << endl;
CreateBiTree(T);
cout << "先序遍历" << endl;
PreOrderTraverse(T, VisitBiTree);
cout << endl;
cout << "中序遍历"<<endl;
InOrderTraverse(T, VisitBiTree);
cout << endl;
InOrderTraverse_2(T, VisitBiTree);
cout << endl;
InOrderTraverse_3(T, VisitBiTree);
cout << endl;
cout << "后序遍历"<<endl;
PostOrderTraverse(T, VisitBiTree);
cout << endl;
cout << "层序遍历"<<endl;
LevelOrderTraverse(T, VisitBiTree);
DestroyBiTree(T);
return 0;
}
结果:(在vs2013��实现,注意要在stadfx.h中包含相应的头文件)
在Java中实现的二叉树结构