poj 2255
来源:互联网 发布:手机拨打电话软件 编辑:程序博客网 时间:2024/06/04 18:24
递归,学会了两个string的函数
substr(),第二个参数是长度;
代码如下
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;struct Node{char data;Node *lchild,*rchild;};Node *create(string pre,string in){Node *root;root=NULL;if(pre.length()>0){root=new Node;root->data=pre[0];int index=in.find(root->data);root->lchild=create(pre.substr(1,index),in.substr(0,index)); root->rchild=create(pre.substr(index+1),in.substr(index+1)); }return root;}void postorder(Node *&root) { if(root!=NULL) { postorder(root->lchild); postorder(root->rchild); cout<<root->data; } } int main(){string pre,in;while(cin>>pre>>in){Node *root; root=create(pre,in); postorder(root); cout<<endl; }return 0; }
阅读全文
0 0
- POJ 2255
- POJ 2255
- POJ 2255
- POJ-2255
- poj 2255
- poj 2255
- POJ 2255
- poj 2255
- poj 2255
- poj 2255
- POJ-2255
- poj 2255
- poj 2255 Tree Recovery
- Tree Recovery---POJ--2255
- POJ 2255 Tree Recovery
- POJ 2255 Tree Recovery
- poj 2255 Tree Recovery
- POJ 2255: Tree Recovery
- 上拉加载,下拉刷新,xlistview
- Tcp协议学习
- C#实现AOP框架
- 神经网络与深度学习学习笔记:向量化与for循环对比
- Windows远程桌面连接设置——同时让两人连接
- poj 2255
- Redis分布式锁----乐观锁的实现,以秒杀系统为例
- Python -html库笔记
- JS中对象与字符串的互相转换
- thinkphp 路由优化
- 正则表达式测试邮箱地址是否合法
- 记一次程序在Windows家庭版上运行.NET Framework DbProvider无法加载解决过程
- 为什么不叫非标准微积分?
- 同时装了Python3和Python2,怎么用pip