-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBj17478Recursion.java
More file actions
36 lines (29 loc) · 1.51 KB
/
Copy pathBj17478Recursion.java
File metadata and controls
36 lines (29 loc) · 1.51 KB
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
package baekjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Bj17478Recursion {
static String underba = "";
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
System.out.println("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.");
recursive(n);
}
private static void recursive(int n) {
String line = underba;
if (n == 0) {
System.out.println(line + "\"재귀함수가 뭔가요?\"");
System.out.println(line + "\"재귀함수는 자기 자신을 호출하는 함수라네\"");
System.out.println(line + "라고 답변하였지.");
return;
}
System.out.println(line + "\"재귀함수가 뭔가요?\"");
System.out.println(line + "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.");
System.out.println(line + "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.");
System.out.println(line + "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"");
underba += "____";
recursive(n - 1);
System.out.println(line + "라고 답변하였지.");
}
}