zoukankan      html  css  js  c++  java
  • 折纸问题

                                                  down

                                        up                      dowm

                    up                       down       up                  down

    观察现象,为一个满二叉树,发现折痕的上面是down,其余的折痕左孩子是up,右孩子是down,显示出所有折痕采用二叉树的中序遍历。

    package com.hzins.suanfa;
    
    public class Zhezhi {
        public static void printAll(int n){
            printProcess(1, n, true);
        }
    
        private static void printProcess(int i, int n, boolean b) {
            if(i > n){
                return ;
            }
            printProcess(i+ 1, n, true);
            System.out.print(b ? "down   " : "up   ");
            printProcess(i + 1, n, false);
        }
        public static void main(String[] args) {
            printAll(7);
        }
    }
  • 相关阅读:
    1.Apache与Tomcat
    jeeplus 多选框
    GIT 回滚
    jsp 中data 转换 字符串
    Pattern和Matcher中表达式
    web.xml 详细介绍
    $.ajax()方法详解
    My 2016
    如何做好一个保安队长。
    集合之WeakHashMap
  • 原文地址:https://www.cnblogs.com/caobojia/p/6762974.html
Copyright © 2011-2022 走看看