import java.util.Scanner;
public class Main {
static String sep = "";
static int i = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.");
recursion(n);
}
public static void recursion(int num) {
String last = "";
System.out.println(sep + "\"재귀함수가 뭔가요?\"");
if (i == num) {
System.out.println(sep + "\"재귀함수는 자기 자신을 호출하는 함수라네\"");
System.out.println(sep + "라고 답변하였지.");
return;
}else {
System.out.println(sep + "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.");
System.out.println(sep + "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.");
System.out.println(sep + "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"");
last = sep + "라고 답변하였지." + last;
}
sep += "____";
i++;
recursion(num);
System.out.println(last);
}
}
public class Main {
static String sep = "";
static int i = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.");
recursion(n);
}
public static void recursion(int num) {
String last = "";
System.out.println(sep + "\"재귀함수가 뭔가요?\"");
if (i == num) {
System.out.println(sep + "\"재귀함수는 자기 자신을 호출하는 함수라네\"");
System.out.println(sep + "라고 답변하였지.");
return;
}else {
System.out.println(sep + "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.");
System.out.println(sep + "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.");
System.out.println(sep + "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"");
last = sep + "라고 답변하였지." + last;
}
sep += "____";
i++;
recursion(num);
System.out.println(last);
}
}
이거 이러케푸는거 마자 형들??
이거 너무 어려웡..
if-else로 안 해도 돼 탈출 조건을 if로 걸고 그냥 리커전 계속 하면 될거야 대단한데 이 어려운 개념을 이해했노
이게 머가어려워 ㅋ반복문수준인데
뭐 이해하고 나면 좆밥이긴한데 이해하기 전에는 통곡의 벽이었음 나한테는
반복문에 true넣고 if에 break넣는거랑 똑같음 ㅋ
감사감사 else빼도 되는구나 잘배우고간당
모바일좆같네 짤려서 안보임 반복문에 넣고 if로 탈출하면 재귀맞음