输入的先序数据为ABC##DE#G##F###
输入数据的 二叉链表图为:
按照中序的规则, 中序输出预期为:CBEGDFA
代码如下:
// 二叉树.cpp: 实现二叉树的创建和中序遍历输出节点数据。
//
#include "stdafx.h"
#include "type.h"
#include "stack.h"
using namespace std;
template <class TElemType>
class Binode {
public:
TElemType data;
Binode *lchild, *rchild;
};
template <class TElemType>
class Bitree
{
public :
Bitree();
~Bitree();
Binode<TElemType> * creatBitree() {
cout << "请输入 节点值" << endl;
TElemType ch;
Binode<TElemType> * t;
cin >> ch;
if (ch == '#') t = NULL;
else {
//if (!(Tree = new Bitree)) exit(overflow_error);
t = new Binode<TElemType>;
t->data =