随笔 - 70  文章 - 160  trackbacks - 0

公告:
知识共享许可协议
本博客采用知识共享署名 2.5 中国大陆许可协议进行许可。本博客版权归作者所有,欢迎转载,但未经作者同意不得随机删除文章任何内容,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 具体操作方式可参考此处。如您有任何疑问或者授权方面的协商,请给我留言。

常用链接

留言簿(8)

随笔档案

文章档案

搜索

  •  

积分与排名

  • 积分 - 176486
  • 排名 - 147

最新评论

阅读排行榜

评论排行榜

欢迎您来到Tanky Woo的博客: 我们的【C++奋斗乐园】 C++/算法网站:www.cpply.com C++/算法论坛:www.cppleyuan.com QQ群:①群:19333724 ②群:23840480 ③群:17314377 ④群:23829384 很经典的递归! 把握前序,中序,后序的特点。 前序的第一个元素是树的根,在相应中序中根以左是左子树,根以右是右子树。 注意考虑 n == 1和 n == 0 的情况。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 // POJ 2255 Tree Recovery // Tanky Woo // Memory: 180K Time: 0MS // Language: C++ Result: Accepted   #include <iostream> #include <string> using namespace std;   //定义前序,中序,后序序列 string preord, inord, postord; void find_postord(string preord, string inord);   // Blog:www.wutianqi.com int main() { while(cin >> preord >> inord) { find_postord(preord, inord); cout << endl; } return 0; }     //找到ch在inord中的位置,未找到返回-1 int find_root(string inord, char ch) { int i; for(i = 0; [...]
文章来源:http://www.wutianqi.com/?p=285
posted on 2010-07-08 18:27 Tanky Woo 阅读(126) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理