<img src="http://img.blog.csdn.net/20141014212549703?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUl9NaXNheWE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
#include<stdio.h>
#include<string.h>
int cont;
char st1[100],st2[100],ans[100];
void build(int n,char *s1,char *s2,char *s)
{
if(n<=0) return;
int p=strchr(s1,s2[n-1])-s1;
ans[cont++]=s2[n-1];
build(p,s1,s2,s);
build(n-p-1,s1+p+1,s2+p,s+p);
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
cont=0;
scanf("%s%s",st1,st2);
int len=strlen(st1);
build(len,st1,st2,ans);
ans[len]='\0';
printf("%s\n",ans);
}
return 0;
}

SDUTOJ 1489 求二叉树的先序遍历的更多相关文章

  1. SDUT 1489 求二叉树的先序遍历 (中序后序还原二叉树)

    求二叉树的先序遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description  已知一 ...

  2. [LeetCode] Binary Tree Postorder Traversal 二叉树的后序遍历

    Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...

  3. [LeetCode] 145. Binary Tree Postorder Traversal 二叉树的后序遍历

    Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...

  4. [leetcode]_根据二叉树的先序遍历(后序遍历) + 中序遍历 重建二叉树

    题目1:Construct Binary Tree from Preorder and Inorder Traversal 给定一棵二叉树的先序遍历和中序遍历,求重建二叉树. 思路: 1.先序遍历的第 ...

  5. [LeetCode] Binary Tree Inorder Traversal 二叉树的中序遍历

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  6. 数据结构《10》----二叉树 Morris 中序遍历

    无论是二叉树的中序遍历还是用 stack 模拟递归, 都需要 O(n)的空间复杂度. Morris 遍历是一种 常数空间 的遍历方法,其本质是 线索二叉树(Threaded Binary Tree), ...

  7. lintcode:Binary Tree Postorder Traversal 二叉树的后序遍历

    题目: 二叉树的后序遍历 给出一棵二叉树,返回其节点值的后序遍历. 样例 给出一棵二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [3,2,1] 挑战 你能使用非递归实现么? 解题: 递归程序 ...

  8. lintcode:二叉树的中序遍历

    题目: 二叉树的中序遍历 给出一棵二叉树,返回其中序遍历 样例 给出二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [1,3,2]. 挑战 你能使用非递归算法来实现么? 解题: 程序直接来源 ...

  9. LeetCode(94):二叉树的中序遍历

    Medium! 题目描述: 给定一个二叉树,返回它的中序 遍历. 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,3,2] 进阶: 递归算法很简单,你可以通过迭代算法完成吗 ...

随机推荐

  1. html中事件处理中的this和event对象

    在用js编写页面事件处理代码时,会经常涉及到this和event对象,但有时在采用不同的事件处理,尤其是在与自定义的对象关联时,这些对象的指向变的有些复杂. 本文来详细介绍下各种场景下 这些对象 真正 ...

  2. 使用Jquery+EasyUI 进行框架项目开发案例解说之二---用户管理源代码分享

    使用Jquery+EasyUI 进行框架项目开发案例解说之二 用户管理源代码分享  在上一篇文章<使用Jquery+EasyUI进行框架项目开发案例解说之中的一个---员工管理源代码分享> ...

  3. 亚马逊带Marketplace product code的image无法再mount到其他镜像上

    这是对已发布镜像的保护么?难道对其进行修改的路彻底断掉了? 以volume形式attach也不行,dd成raw再读取也读不了,敢问路在何方呢 If a volume has an AWS Market ...

  4. ultraedit比较两个文件差异经验

    链接地址:http://jingyan.baidu.com/article/fcb5aff7876551edab4a714b.html 程序开发人员经常要使用到两个文件的对比,有很多工具可以实现该功能 ...

  5. (解决tomcat端口被占用的问题)create[8005]java.net.BindException: Address already in use: JVM_Bind

    create[8005]java.net.BindException: Address already in use: JVM_Bind”,原来是Tomcat8005端口被其他进程占用,8005端口是 ...

  6. date、datetime、string的相互转换

    import datetime import time string转datetime str = '2012-11-19' date_time = datetime.datetime.strptim ...

  7. UVALive 6584 Escape (Regionals 2013 >> Europe - Central)

    题目 给出一棵树,每个节点有一个怪物或血药,遇到怪物必须打,打完后扣掉一定的血量. 一开始英雄的血量为\(0\),当血量小于\(0\)时就挂了. 给出英雄的起点和终点,问能否成功到达终点. 算法 这题 ...

  8. Linux笔记——linux下的语音合成系统

    1.festival 安装:sudo apt-get install festival 使用: (SayText "Hello!") 2. espeek(ubuntu 自带) # ...

  9. URAL 1792. Hamming Code (枚举)

    1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersectin ...

  10. Win7+花生壳6.0+tomcat打做自己的web服务器(搭建自己的网站)(参考)

    链接地址:http://blog.csdn.net/zhu_9527/article/details/23344623?utm_source=tuicool&utm_medium=referr ...