알고리즘
백준 17478번 재귀함수가 뭔가요? C++
영춘권의달인
2022. 9. 12. 21:26
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
#include <bitset>
using namespace std;
using int64 = long long;
#define Print for (int i = 0; i < cnt; i++) cout << str;
int n;
string str = "____";
void Rec(int cnt) {
if (n == cnt) {
Print; cout << "\"재귀함수가 뭔가요?\"\n";
Print; cout << "\"재귀함수는 자기 자신을 호출하는 함수라네\"\n";
Print; cout << "라고 답변하였지.\n";
return;
}
Print; cout << "\"재귀함수가 뭔가요?\"\n";
Print; cout << "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.\n";
Print; cout << "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.\n";
Print; cout << "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"\n";
Rec(cnt + 1);
Print; cout << "라고 답변하였지.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
cout << "어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.\n";
Rec(0);
}