#include <bits/stdc++.h>
using namespace std;
struct Tree
{
char data;
struct Tree *right;
struct Tree *left;
};
char str[55];
int num;
struct Tree *creat()
{
struct Tree * root;
if(str[num ++] == ',')
{
root = NULL;
}
else
{
root = (struct Tree *)malloc(sizeof(struct Tree));
root -> data = str[num - 1];
root -> left = creat();
root -> right = creat();
}
return root;
}
void inorder(struct Tree * root)
{
if(root)
{
inorder(root -> left);
printf("%c", root -> data);
inorder(root -> right);
}
}
void postorder(struct Tree * root)
{
if(root)
{
postorder(root -> left);
postorder(root -> right);
printf("%c", root -> data);
}
}
int main()
{
while(~scanf("%s",str))
{
num = 0;
struct Tree * root;
root = creat();
inorder(root);
printf("\n");
postorder(root);
printf("\n");
}
return 0;
}

最新文章

  1. MongoDB索引
  2. .Net的内置对象之一 Request
  3. Eclipse启动tomcat,http://localhost:8080/无法访问的解决方法
  4. 微信小程序-媒体组件
  5. java对txt文件内容追加
  6. web服务器安装配置
  7. Codeforces Round #131 (Div. 1) B. Numbers dp
  8. MyEclipse2015 编写js报 &#39;Calculating completion proposals..&#39; has encountered a problem.
  9. Unix编程之size_t、ssize_t
  10. AngularJS 学习随笔(一)
  11. WVGA-维基百科
  12. sgu 101 domino
  13. 回收进程用户空间资源 exit()函数 _exit()函数 atexit()函数 on_exit()函数
  14. Bluetooth 2.1+EDR是什么
  15. MySQL FEDERATED 存储引擎
  16. jquery-ui-multiselect 的使用
  17. Node.js 子进程
  18. git版本控制工具的使用
  19. mybatis入门篇:Mybatis注解方式的基本用法
  20. bzoj2190

热门文章

  1. LeetCode 1047. Remove All Adjacent Duplicates In String
  2. Android蓝牙遥控器APP关键代码 guihub项目
  3. 微软升级 WSL Window Subsystem for Linux Win10系统自带Linux
  4. css手册中各种符号的意思
  5. JavaScript--常用对象的属性及方法(2)
  6. ES6 class 于 继承 extends
  7. SAP Marketing Cloud的Contact导入配置和数据合并原理
  8. Java实现 Cookie的生成与读取
  9. YII2 实现dropDownList 联动事件
  10. dockerfile构建nginx