#include <stdio.h>
#include <stdlib.h>
#define ElemType char //二叉树中数据元素类型
#include "bintree.h" //二叉树的实现
///////////////////////////////////////////////////////////
// 主程序
int main()
{
BiTree bt = 0;
//建立二叉树
printf("建立二叉树(按先序输入二叉树中的结点,空格表示空树)\n");
if( CreateBiTree(bt)==ERROR ) {
printf("ERROR: call CreateBiTree\n");
system("pause");
exit(1);
}
PrintTree(bt);
SqStack s;
InitStack(s); //初始化栈
printf("\n非递归先序遍历二叉树:\n ");
PrePrint(bt,s); //先序
printf("\n非递归中序遍历二叉树:\n ");
MidPrint(bt,s); //中序
printf("\n非递归后序遍历二叉树:\n ");
LatPrint(bt,s); //后序
printf("\n");
system("pause"); //暂停以便查看结果
return 0;
}
评论0
最新资源