-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
51 lines (40 loc) · 1.03 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*************************************************************************
> File Name: test.cpp
> Author: zhanglp
> Mail: 820221185@qq.com
> Created Time: 2014年03月03日 星期一 19时22分36秒
************************************************************************/
#include <string>
#include "BinaryTree.h"
using std::string;
using std::cin;
using std::cout;
using std::endl;
void createTree (BinaryTree<int>::node_type *p)
{
int val;
BinaryTree<int>::node_type *q;
cout << "val (" << p->data << " = left) : ";
cin >> val;
if (val) {
q = BinaryTree<int>::InsertNode (
p, val, BinaryTree<int>::left_child);
createTree (q);
}
cout << "val (" << p->data << " = right) : ";
cin >> val;
if (val) {
q = BinaryTree<int>::InsertNode (
p, val, BinaryTree<int>::right_child);
createTree (q);
}
}
int main (void)
{
BinaryTree<int> tree (1);
int t, i;
BinaryTree<int>::node_type *p = tree.root ();
createTree (p);
print_BiTree (cout, *tree.root ());
return 0;
}