Tree Recovery
#include<stdio.h>
#include<string.h>
void build(int n,char*s1,char*s2)
{
if(n<=)return ;
int p=strchr(s2,s1[])-s2;///p表示左结点的个数
build(p,s1+,s2);///查找左结点
build(n-p-,s1+p+,s2+p+);///查找右结点
printf("%c",s1[]);///输出每次递归的结点值
}
int main()
{
char s1[],s2[];
memset(s1,,sizeof(s1));
memset(s2,,sizeof(s2));
while(scanf("%s %s",s1,s2)!=EOF)
{
int n=strlen(s1);
build(n,s1,s2);
printf("\n");
}
return ;
}
Tree Recovery的更多相关文章
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- Tree Recovery(前序中序求后序)
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14640 Accepted: 9091 De ...
- poj 2255 Tree Recovery 分治
Tree Recovery Description Little Valentine liked playing with binary trees very much. Her favorite g ...
- Tree Recovery POJ - 2255
Tree Recovery POJ - 2255 根据树的前序遍历和中序遍历还原后序遍历. (偷懒用了stl的find) #include<iostream> #include<st ...
- 2018年全国多校算法寒假训练营练习比赛(第五场)H Tree Recovery
Tree Recovery 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 链接:https://w ...
- POJ 2255 Tree Recovery 二叉树的遍历
前序和中序输入二叉树,后序输出二叉树:核心思想只有一个,前序的每个根都把中序分成了两部分,例如 DBACEGF ABCDEFG D把中序遍历的结果分成了ABC和EFG两部分,实际上,这就是D这个根的左 ...
- Tree Recovery(由先、中序列构建二叉树)
题目来源: http://poj.org/problem?id=2255 题目描述: Description Little Valentine liked playing with binary tr ...
- poj 2255 Tree Recovery(求后序遍历,二叉树)
版权声明:本文为博主原创文章,未经博主同意不得转载.vasttian https://blog.csdn.net/u012860063/article/details/37699219 转载请注明出处 ...
- B - Tree Recovery
Little Valentine liked playing with binary trees very much. Her favorite game was constructing rando ...
- UVa 536 Tree Recovery(二叉树后序遍历)
Little Valentine liked playing with binary trees very much. Her favorite game was constructing rando ...
随机推荐
- 外部调用mvc的api方法时,如何解决跨域请求问题?
首先,创建一个mvc项目(包含webapi),我们模拟一个场景 1)在项目的Controller 创建一个WeiXinApiController public class WeiXinApiContr ...
- @NotNull, @NotEmpty和@NotBlank之间的区别是什么?
首先是简要描述: [java] view plain copy@NotNull://CharSequence, Collection, Map 和 Array 对象不能是 null, 但可以是空集(s ...
- js--阻止冒泡,捕获,默认行为
防止冒泡和捕获 w3c的方法是e.stopPropagation(),IE则是使用e.cancelBubble = true· var el = window.document.getElementB ...
- zabbix3.4.7安装在centos 7.4上
Centos 7.4 安装Zabbix 3.4 一.安装环境 1 [root@juny-18 ~]# cat /etc/redhat-release 2 3 CentOS Linux release ...
- VIM编辑配置文件基本操作
vim /etc/apt/sources.list 按insert键进入编辑状态 编辑完成以后按ESC退出编辑状态 输入 ":"进入命令状态,常用命令: 1.W:write ,写 ...
- AdaBoost, LogitBoost and GradientBoosting
前向分步算法与加法模型(forward stagewise algorithm and additive model) (1) AdaBoost:前向分步算法中损失函数取指数损失函数 (2) Logi ...
- learning scala control statement
1 .if satement 与其它语言不同的是,scala if statement 返回的是一个值 scala> val a = if ( 6 > 0 ) 1 else -1a: In ...
- python-小数据池 and 编码
# id()函数可以帮我们查看一个变量的内存地址 # a = 10 # b = 30 # print(id(a)) # 1515545088 # print(id(b)) # 1515545728 # ...
- day23 模块02
核能来袭--模块 2 1.nametuple() 2.os模块 3.sys模块(重点) 4.序列化 (四个函数) 5.pickle(重点) 6.json(重点中的重点) 1.nametuple() 命 ...
- 深入理解Connector
上一篇主要是从各个容器的生命周期的角度讲了一下整个tomcat的运行流程,说明了各个容器之间的调用关系.但并没有太过详细的说明每一个组件并区分他们. 下面从功能的角度上详细的分析一下connector ...