0.唔。这道题 首先要明确根节点在哪儿 初始化成pos=maxn/2;

1.因为是先序的输入方法,所以这个建树的方法很重要

 void build(int p)
 {
     int v;
     cin>>v;

     )
     {
         sum[p]+=v;
         build(p-),build(p+);
     }
 }
 #include  <iostream>
 #include <cstring>
 using namespace std;
  ;
 int sum[maxn];
 int k;
 void build(int p)
 {
     int v;
     cin>>v;

     )
     {
         sum[p]+=v;
         build(p-),build(p+);
     }

 }
 void output()
 {
     cout<<"Case "<<++k<<":"<<endl;
     ;
     ) p++;

     cout<<sum[p++];

     )
         cout<<" "<<sum[p++];
     cout<<endl<<endl;
 }
 int main()
 {
     int root;
     k=;
     while(cin>>root)
     {
         memset(sum,,sizeof(sum));
         ) break;
         ;
         sum[pos]=root;

         build(pos-);
         build(pos+);

         output();

     }
     ;
 }

Uva 699The Falling Leaves的更多相关文章

  1. UVA - 699The Falling Leaves(递归先序二叉树)

    The Falling Leaves Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Sub ...

  2. UVA 1525 Falling Leaves

    题目链接:https://vjudge.net/problem/UVA-1525 题目链接:https://vjudge.net/problem/POJ-1577 题目大意 略. 分析 建树,然后先序 ...

  3. UVA.699 The Falling Leaves (二叉树 思维题)

    UVA.699 The Falling Leaves (二叉树 思维题) 题意分析 理解题意花了好半天,其实就是求建完树后再一条竖线上的所有节点的权值之和,如果按照普通的建树然后在计算的方法,是不方便 ...

  4. UVa 699 The Falling Leaves(递归建树)

    UVa 699 The Falling Leaves(递归建树) 假设一棵二叉树也会落叶  而且叶子只会垂直下落   每个节点保存的值为那个节点上的叶子数   求所有叶子全部下落后   地面从左到右每 ...

  5. UVA 699 The Falling Leaves (二叉树水题)

    本文纯属原创.转载请注明出处,谢谢. http://blog.csdn.net/zip_fan. Description Each year, fall in the North Central re ...

  6. UVa 699 The Falling Leaves (树水题)

    Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on ...

  7. The Falling Leaves(建树方法)

    uva 699 紫书P159 Each year, fall in the North Central region is accompanied by the brilliant colors of ...

  8. H - The Falling Leaves

    Description Each year, fall in the North Central region is accompanied by the brilliant colors of th ...

  9. UVa699 The Falling Leaves

      // UVa699 The Falling Leaves // 题意:给一棵二叉树,每个节点都有一个水平位置:左儿子在它左边1个单位,右儿子在右边1个单位.从左向右输出每个水平位置的所有结点的权值 ...

随机推荐

  1. IOS-在ARC项目中使用非ARC框架或者类库

    1.在ARC项目中使用非ARC框架或者类库 IOS 4引入了Automatic Reference Count(ARC),编译器可以在编译时对obj-c对象进行内存管理. 之前,obj-c的内存管理方 ...

  2. ui组件--弹出层layer的使用

    帮助文档 下载地址 演示地址

  3. 数据存储-CoreData总结

    CoreData /*英译  Entity:实体 Attributes:属性 binary:二进制 persistent:持续化 coordinator:协调者 meging:合并 configura ...

  4. 谈谈我的编程之路---WAMP(二)

    WAMP的一些配置与使用心得(MYSQL) 刚开始接触数据库的时候,我一直认为数据库操作工具和数据库是同一种东西,它们是一体的,后来我才明白,数据库它是一个独立的仓库,用官方点的话来解释 数据库(Da ...

  5. Java -- String、StringBuffer、StringBuilder

    原文:http://blog.csdn.net/kingzone_2008/article/details/9220691 String:不可变. StringBuffer(JDK1.0):可变,线程 ...

  6. WPA: 4-Way Handshake failed - pre-shared key may be incorrect

    生成psk网址: https://www.wireshark.org/tools/wpa-psk.html 相关 bug: 重点 关注 : https://en.community.sonos.com ...

  7. ListView 完全优化 + 多种listitem布局处理

    #  百度了下,感觉下面的博客文章还都挺全面的,写的很好,直接分享得了 Android性能优化--Listview优化 - tonycheng93 - 博客园http://www.cnblogs.co ...

  8. 使用Delphi对象(声明、实例化、构造、释放)

    一.声明和实例化 在使用一个对象之前,用class关键字声明一个对象.可以在一个程序或单元的type部分声明一个对象类型: type TFooObject = class; 除了声明一个对象类型,通常 ...

  9. Mysql中文乱码问题完美解决方案

    drop database`netctoss_demo` ;CREATE DATABASE `netctoss_demo` CHARACTER SET 'utf8' COLLATE 'utf8_gen ...

  10. c++ 的 static_cast

    http://www.cnblogs.com/pigerhan/archive/2013/02/26/2933590.html #include "Person.h" #inclu ...