-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.java
42 lines (31 loc) Β· 1.57 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package Recursion.P17478;
import java.io.*;
public class Main {
static int N;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
N = Integer.parseInt(br.readLine());
sb.append("μ΄λ ν μ»΄ν¨ν°κ³΅νκ³Ό νμμ΄ μ λͺ
ν κ΅μλμ μ°Ύμκ° λ¬Όμλ€.\n");
recursive(0);
bw.write(sb.toString());
bw.flush();
bw.close();
br.close();
}
static void recursive(int cnt) {
StringBuilder indent = new StringBuilder();
for (int i = 0; i < cnt; i++) indent.append("____");
sb.append(indent).append("\"μ¬κ·ν¨μκ° λκ°μ?\"\n");
if (cnt == N) {
sb.append(indent).append("\"μ¬κ·ν¨μλ μκΈ° μμ μ νΈμΆνλ ν¨μλΌλ€\"\n");
} else {
sb.append(indent).append("\"μ λ€μ΄λ³΄κ². μλ μλ ν μ° κΌλκΈ°μ μ΄μΈμ λͺ¨λ μ§μμ ν΅λ¬ν μ μΈμ΄ μμμ΄.\n");
sb.append(indent).append("λ§μ μ¬λλ€μ λͺ¨λ κ·Έ μ μΈμκ² μλ§μ μ§λ¬Έμ νκ³ , λͺ¨λ μ§νλ‘κ² λλ΅ν΄ μ£Όμμ§.\n");
sb.append(indent).append("κ·Έμ λ΅μ λλΆλΆ μ³μλ€κ³ νλ€. κ·Έλ°λ° μ΄λ λ , κ·Έ μ μΈμκ² ν μ λΉκ° μ°Ύμμμ λ¬Όμμ΄.\"\n");
recursive(cnt + 1);
}
sb.append(indent).append("λΌκ³ λ΅λ³νμμ§.\n");
}
}