二叉树的遍历
来源:互联网 发布:阿里云个人邮箱登录 编辑:程序博客网 时间:2024/06/03 23:46
#include <stdio.h>#include <string.h>#include<iostream>#include<cmath>using namespace std;typedef long long LL;string a,b;void pre_vis(int a_begin,int a_end,int b_begin,int b_end){ if(a_begin > a_end) return ; int i; char root = a[a_begin]; for(i = b_begin; b[i] != root; i++); pre_vis(a_begin + 1, a_end - b_end + i,b_begin,i-1); pre_vis(a_end - b_end + i +1, a_end, i+1,b_end); cout<<root;}void las_vis(int a_begin,int a_end,int b_begin,int b_end){ if(a_begin > a_end) return ; int i ; char root = a[a_end]; cout<<root; for(i = b_begin; b[i] != root; i++); las_vis(a_begin, a_end - b_end + i -1,b_begin, i-1); las_vis(a_end - b_end +i, a_end -1, i + 1,b_end);}int main(){ while(cin>>a>>b) { int len_a = a.size(); int len_b = b.size(); //pre_vis(0,len_a-1,0,len_b-1); las_vis(0,len_a-1,0,len_b-1); } return 0;}
0 0
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- 二叉树的遍历
- POJ 2208 Pyramids&&HDU 1411 校庆神秘建筑(欧拉四面体公式)
- C++ Set 容器
- Linux中inode的理解
- Libcurl使用OpenSSL编译出现undefined reference to `COMP_CTX_free'错误备忘
- 在asp.net中使用excel模板
- 二叉树的遍历
- 为什么调用 FragmentPagerAdapter.notifyDataSetChanged() 并不能更新其 Fragment?
- 数据结构 - 表插入排序 详解 及 代码(C++)
- 一个小问题。
- jquery的ajax请求与springMVC交互
- 什么是反向代理?
- 使用js判断是手机访问还是电脑访问
- 获取屏幕尺寸大小和密度
- python统计汉字词频