poj2255 Tree Recovery
来源:互联网 发布:淘宝秒杀抢拍器怎么买 编辑:程序博客网 时间:2024/05/30 23:00
//前序遍历、中序遍历,求后序遍历(利用递归的非建树方法)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char pr[27],in[27];
int len;
void cal(int l1,int r1,int l2,int r2){
if(l1>r1)return;
char root=pr[l1];
int i;
for(i=l2;in[i]!=root;i++);
cal(l1+1,l1+i-l2,l2,i-1);
cal(l1+i-l2+1,r1,i+1,r2);
cout<<root;
}
int main(void){
while(scanf("%s %s",&pr,&in)!=EOF){
len=strlen(pr);
cal(0,len-1,0,len-1);
cout<<endl;
}
return 0;
}
0 0
- POJ2255 Tree Recovery
- poj2255 Tree Recovery
- poj2255 Tree Recovery
- POJ2255-Tree Recovery
- poj2255 Tree Recovery(递归)
- POJ2255----Tree Recovery
- POJ2255,Tree Recovery,二叉树重建
- poj2255 Tree Recovery 二叉树遍历
- poj2255~~Tree Recovery (树的遍历构造~)
- poj2255- Tree Recovery(二叉树)
- POJ2255 Tree Recovery 前序 中序求后序
- POJ2255 Tree Recovery 【树的遍历】
- POJ2255 Tree Recovery 二叉树遍历
- POJ2255 Tree Recovery (先序中序-》后序)
- POJ2255 Tree Recovery(二叉树遍历)
- 【POJ2255】Tree Recovery解题报告 思路 + 数据 +代码
- poj2255 Tree Recovery 二叉树,这题整我好惨
- poj2255——Tree Recovery(应用二叉树)
- poj2236 Wireless Network
- Sicily 1620 SCVs and minerals
- SQL Server未将服务器 123.15.50.82 配置为用于 DATA ACCESS
- NumberFormat在数字格式化中的使用
- 关于ios手机端的屏幕像素点
- poj2255 Tree Recovery
- Bean-Query 功能改进版(1.1.0)已发布
- SDWebImage 原理及使用
- Sicily 1624 Cryptoquote
- ssh框架
- UI基础-基础控件-0324-transform应用-使用transform实现btn小案例
- SharePoint Search之(八) 搜索中心站点
- Android Notification通知简单使用DEMO
- 控制界面切换的动画效果