본문 바로가기
알고리즘 & 자료구조/백준

백준 17478

by 신재권 2021. 11. 26.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main17478 {

	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("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.");
		String str = "";
		recursive(N, str);

	}
	
	public static void recursive(int N, String str){
		
		if(N<0){
			return;
		}
		System.out.println(str+"\"재귀함수가 뭔가요?\"");
		if(N == 0){
			System.out.println(str+"\"재귀함수는 자기 자신을 호출하는 함수라네\"");
			System.out.println(str+"라고 답변하였지.");
			return;
		}
		
		System.out.println(str+"\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.");
		System.out.println(str+"마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.");
        System.out.println(str+"그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"");
		recursive(N-1,str+"____");
		
		System.out.println(str+"라고 답변하였지.");
		
	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 2422  (0) 2021.11.28
백준 2628  (0) 2021.11.27
백준 4796  (0) 2021.11.25
백준 15685  (0) 2021.11.24
백준 1032  (0) 2021.11.23