- basecondition을 정의한다.(문제에서 case 0이 주어져서 설정하기 쉬움)
- f(basecondition)−>f(basecondition+1)의 관계에서 f(n)−>f(n+1)의 점화식을 발견한다.
- 점화식에 따른 함수를 정의한다.
#include <bits/stdc++.h>
using namespace std;
int N;
void cantour(int n){
if(n == 0) {
cout << '-';
return;
}
cantour(n-1);
for(int i = 0; i < pow(3, (n - 1)); ++i) cout << ' ';
cantour(n-1);
}
int main(){
while(cin >> N){
cantour(N);
cout << '\n';
}
return 0;
}