六.界面设计
当用户还没有创建二叉树时,提示用户输入数据:
Please input char to the binatree, @ to exit current node:
Please input a char:
当用户,创建了二叉树之后,出现控制菜单:
Please choose the mode you want to operate with the binatree:
1.display 2.preOrder 3.inOrder 4.postOrder 5.leaves 6.free nodes 0 to exit:
七.程序的调试:
1. 测试完全二叉树的情形:
输入(每输入一个字符回车一次):A B C @ @ D @ @ E F @ @ G @ @
自动的打印出树型结构:
Display the binatree data directly:
G
E
F
A
D
B
C
三种遍历方式和叶子结点,测试如下:
先根:
Data in preOrder:
A B C D E F G
中根:
Data in inOrder:
C B D A F E G
后根:
Data in postOrder:
C D B F G E A
打印叶子结点:
Leaves:
C D F G
释放所有结点空间:
Free all nodes:
All node have been freed successfully.
自动提示创建一棵新的二叉树:
Now creating a new binatree...
Please input char to the binatree, @ to exit current node:
Please input a char:
2测试非完全二叉树的情形
输入(每输入一个字符回车一次):A B C D @ @ @ @ @
自动的打印出树型结构:
A
B
C
D
三种遍历方式和叶子结点,测试如下:
先根:
Data in preOrder:
A B C D
中根:
Data in inOrder:
D C B A
后根:
Data in postOrder:
D C B A
打印叶子结点:
Leaves:
D
释放所有结点空间:
Free all nodes:
All node have been freed successfully.
自动提示创建一棵新的二叉树:
Now creating a new binatree...
Please input char to the binatree, @ to exit current node:
Please input a char:
如果我们想结束此次的操作,退出本程序,就可以输入0,程序自动的释放所有的结点空间:
Please choose the mode you want to operate with the binatree:
1.display 2.preOrder 3.inOrder 4.postOrder 5.leaves 6.free nodes 0 to exit:0
Dealing with the last job, to free all nodes
All node have been freed successfully
上一页 下一页






