diff --git "a/_sunha/BOJ22856_\355\212\270\353\246\254\354\210\234\355\232\214.java" "b/_sunha/BOJ22856_\355\212\270\353\246\254\354\210\234\355\232\214.java" new file mode 100644 index 00000000..5517220f --- /dev/null +++ "b/_sunha/BOJ22856_\355\212\270\353\246\254\354\210\234\355\232\214.java" @@ -0,0 +1,70 @@ +/** BOJBOJ22856_트리순회 + * # 문제 + * - + * + * # 제한 + * + * + * # 풀이 + * + * + */ + +import java.io.*; + +public class BOJ22856_트리순회 { + + static class Node { + int left, right; + + void set(int left, int right) { + this.left = left; + this.right = right; + } + } + + static int N, cnt, endNode; + static Node[] tree; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + + String[] temp; + tree = new Node[N+1]; + int now; + for (int n=0; n 0) { + travel(tree[now].left); + cnt++; + } + + if (tree[now].right > 0) { + travel(tree[now].right); + cnt++; + } + + if (now == endNode) { + System.out.println(cnt - 1); // 시작점 카운트(1) 제외하고 출력 + } + + } +}