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
查看全文
相关阅读:
多线程2
多线程1
Mybatis动态代理开发
Mybatis的mapper.xml文件也是要加文件头的
ssm框架只使用mybatis配置sqlmapconfig.xml
ssm整合之web.xml配置
SpringMVC三大组件的配置
spring开启注解配置
如何开发 Sublime Text 2 的插件
ASP.NET MVC 5改进了基于过滤器的身份验证
原文地址:https://www.cnblogs.com/junnyfeng/p/192929.html
最新文章
Python常见序列详解
Python中的四种数据结构
数据结构:八大数据结构分类
lambda表达式在解决java后台分组排序时的应用
Kettle — 使用手册
PostgreSQL日期加减
java.lang.String和java.util.NClob互相转换
关于oracle sql语句查询时表名和字段名要加双引号的问题详解
cas的单点登录实现
解决使用Navicat 打开 Linux远程连接mysql很慢的方法
热门文章
redis安装(Linux版)
Linux安装MySQL5.7
Eclipse.自动提示--编写HTML/CSS/JS/JSP代码时自动提示的解决办法
Spring Boot 注解大全,真是太全了!
jsp表单提交中文乱码方式----提交方式为:post
jsp表单提交中文乱码方式----提交方式为:get
解决:eclipse下tomcat启动正常但无法加载项目,访问404
Oracle | 修改Oracle数据库的字符集为utf-8
DateTimeFormat注解
mysql删除表的三种方式
Copyright © 2011-2022 走看看