POJ 3437 Tree Grafting
来源:互联网 发布:台湾衰落知乎 编辑:程序博客网 时间:2024/05/29 07:35
//思路: 二叉树中X节点的高 = 二叉树中X的父节点的高 + X是第几个儿子
#include <iostream> #include<string>using namespace std; string s; int i,n=0,height1,height2; void work(int level1,int level2){ int tempson=0; while (s[i]=='d'){ i++; tempson++; //tempson 代表第几个 儿子work(level1+1,level2+tempson); } height1=level1>height1?level1:height1; height2=level2>height2?level2:height2; i++; } int main() { while (cin>>s && s!="#"){ i=height1=height2=0; work(0,0); cout<<"Tree "<<++n<<": "<<height1<<" => "<<height2<<endl; } return 0; }
0 0
- POJ 3437 Tree Grafting
- POJ 3437 Tree Grafting
- POJ 3437 Tree Grafting
- POJ 3437 Tree Grafting
- POJ---3437-Tree Grafting
- Tree Grafting(POJ 3437)
- POJ 3437 Tree Grafting 多叉树转二叉树
- POJ 3437 Tree Grafting(二叉树高度)
- Tree Grafting
- Tree Grafting
- POJ 3437 Tree Grafting(有序树转化为二叉树)
- Poj Tree Grafting 解题报告 (左儿子右兄弟)
- (二叉树递归)A - Tree Grafting(9.1.1)
- Tree Grafting,树转换成二叉树,tree recovery,遍历顺序确定二叉树
- po3437求出有序树转化为二叉树前后的高度 Tree Grafting
- POJ Tree
- Tree POJ
- poj-2255-Tree Recovery(tree)
- Python 的内存管理
- 双边滤波器的原理及实现
- 终于把 VIJOS 源代码调试好了
- pwd
- Hibernate笔记(2)
- POJ 3437 Tree Grafting
- SGU 548
- IT忍者神龟之XHTML教程
- SGU 551
- uva 1485 - Permutation Counting(递推)
- HDU2545:树上战争
- 动态判断文字大小,动态排版
- 线段树--Color the ball(多次染色问题)
- python 视频处理,提取视频相关帧,读取Excel