060 折纸问题
Table of Contents

ac

import java.util.*;


public class Main {

    public static Scanner sc = new Scanner(System.in);

    // 根左右,中序遍历
    static void rev(int i, int n, boolean isDown){
        if(i > n){
            return;
        }
        rev(i+1, n, true);
        if(isDown){
            System.out.println("down");
        }else {
            System.out.println("up");
        }
        rev(i + 1, n, false);
    }

    // 根左右,中序遍历
    static String revStr(int i, int n, boolean isDown){
        if(i > n){
            return "";
        }
        StringBuilder sb = new StringBuilder();
        String s1 = revStr(i+1, n, true);
        String s2;
        if(isDown){
           s2 = "down\n";
        }else {
            s2 = "up\n";
        }
        String s3 = revStr(i + 1, n, false);
        sb.append(s1);
        sb.append(s2);
        sb.append(s3);
        String rs = sb.toString();
        return rs;
    }


    public static void main(String[] args) {
        int n = sc.nextInt();
        System.out.print(revStr(1, n, true));
//        rev(1, n ,true);
    }

}
/*
    down
  down   up
down up down up

1

down

2

down
down
up
 */