设为首页 加入收藏

TOP

SDUTOJ 1489 求二叉树的先序遍历
2015-07-20 17:29:01 来源: 作者: 【 】 浏览:2
Tags:SDUTOJ 1489
\
#include
  
   
#include
   
     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; } 
   
  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1503 Advanced Fruits[ LCS ] 下一篇AsyncSocket中tag参数的用处

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)