zoukankan
html css js c++ java
打印树
利用了树的中序遍历,不过是从右边到左边的中序遍历。
#include
<
iostream.h
>
#include
"
tree.h
"
template
<
class
NODETYPE
>
void
outputTree(TreeNode
<
NODETYPE
>
*
ptr,
int
totalSpaces)
{
if
(ptr
!=
0
)
{
outputTree(ptr
->
rightPtr,totalSpaces
+
5
);
for
(
int
i
=
0
;i
<
totalSpaces;i
++
)
cout
<<
'
'
;
cout
<<
ptr
->
getData()
<<
endl;
outputTree(ptr
->
leftPtr,totalSpaces
+
5
);
}
}
int
main()
{
Tree
<
int
>
intTree;
int
intVal;
cout
<<
"
Enter 15 integer valuse\n
"
;
for
(
int
i
=
0
;i
<
15
;i
++
)
{
cin
>>
intVal;
intTree.insertNode(intVal);
}
outputTree(intTree.rootPtr,
0
);
return
0
;
}
运行结果:
99
97
92
83
72
71
69
49
44
40
32
28
19
18
11
查看全文
相关阅读:
利用opengl画一个水波的曲面
Eclipse 使用OpenGL
Javascript学习过程(二)
Workflow Learing
YAWL设计实例
YAWL使用方法
ImageJ二次开发学习纪录之初步体会
[LeetCode 660] Remove 9
[LeetCode 1542] Find Longest Awesome Substring
[LeetCode 879] Profitable Schemes
原文地址:https://www.cnblogs.com/junnyfeng/p/192929.html
最新文章
[BZOJ5329][Sdoi2018]战略游戏 圆方树+虚树
[BZOJ3531][Sdoi2014]旅行 树链剖分
[BZOJ2730][HNOI2012]矿场搭建 点双 割点
[BZOJ1853][Scoi2010]幸运数字 容斥+搜索剪枝
D3中的each() 以及svg defs元素 clipPath的使用
安卓ios和angularjs相互调用解决首次调用ios传递标题失败的问题
移动端使用rem同时适应安卓ios手机原理解析,移动端响应式开发
angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic
angularjs中使用轮播图指令swiper
AngularJS入门教程:日期格式化
热门文章
js中的||与&&用法
document.documentElement和document.body的区别
JS判断字符串长度
利用rem解决移动端响应适配问题
css3中outline切换动画效果
浏览器对document.all的支持差异
关于new Option()
jquery中attr和prop的区别
getComputedStyle与currentStyle获取样式(style/class)
Javascript排序问题
Copyright © 2011-2022 走看看