1 #include <iostream>
2 #include"二叉树.h"
3
4 using namespace std;
5
6 int main()
7
8 {
9 BinaryTree<char> tree;
10 TreeNode<char> 加,减,乘,除,a,b,c,d,e;
11
12 加.data = '+';
13 减.data = '-';
14 乘.data = '*';
15 除.data = '/';
16
17 a.data = 'A';
18 b.data = 'B';
19 c.data = 'C';
20 d.data = 'D';
21 e.data = 'E';
22
23 tree.root = &加;
24 加.leftChild = &减;
25 加.rightChild = &e;
26 减.leftChild = &乘;
27 减.rightChild = &d;
28 乘.leftChild = &除;
29 乘.rightChild = &c;
30 除.leftChild = &a;
31 除.rightChild = &b;
32
33 cout << "中序遍历" << endl;
34 tree.InOrder();//中序遍历
35 cout << endl;
36
37 cout << "前序遍历" << endl;
38
39 tree.PreOrder();
40 cout << endl;
41
42
43 cout<< "层序遍历"<< endl;
44 tree.LevelOrder();
45 cout<< endl;
46 return 0;
47 }