HDOJ 1710
来源:互联网 发布:h5斗牛源码怎么用 编辑:程序博客网 时间:2024/05/25 21:36
#include <iostream>#include <cstdio>#include <cstring>using namespace std;void build(int n,int *s1,int *s2,int *s){ if(n<=0) return; int p; for(int i=0; i<n; i++) { if(s1[0]==s2[i]) { p=i; } } build(p,s1+1,s2,s); build(n-p-1,s1+p+1,s2+p+1,s+p); s[n-1]=s1[0];}const int MAXN=1001;int s1[MAXN],s2[MAXN],ans[MAXN];int main(){ int n; while(cin>>n) { for(int i=0; i<n; i++) { cin>>s1[i]; } for(int i=0; i<n; i++) { cin>>s2[i]; } build(n,s1,s2,ans); for(int i=0; i<n; i++) { printf("%d",ans[i]); if(i<n-1) printf(" "); } cout<<endl; } return 0;}
二叉树知道先序遍历和中序遍历求后序遍历。。。可惜PE了一次,坑爹啊
- HDOJ 1710
- HDOJ
- hdoj
- hdoj
- HDOJ
- hdoj 1568 && hdoj 5344 && hdoj 5444
- HDOJ 1710 Binary Tree Traversals 二叉树先序中序求后续(白书)
- HDOJ 题目1710 Binary Tree Traversals(二叉搜索树)
- HDOJ 1710Binary Tree Traversals 二叉树的遍历
- HDOJ 2176
- Hdoj--1272
- hdoj 1003
- hdoj 1005
- hdoj 1030
- hdoj 2154
- hdoj 2100
- HDOJ 1106
- hdoj 1257
- Spring源代码解析(二):IoC容器在Web容器中的启动
- Miller-Rabin素性检测
- Java 运行原理
- windows下配置nginx+php环境 (可用版)
- (二) Mysql存储引擎
- HDOJ 1710
- 打球的巅峰体验
- 国家气象局天气预报JSON数据接口详解
- ruby+selenium-webdriver一步一步完成自动化测试----生成测试报告
- Struts2 Action间如何传值
- 毕业半年,我是如何从一名程序员成长为一名‘准’项目经理
- 巴巴运动网(11--15)
- MFC应用程序中添加控制台窗口
- hibernate连接存储过程