문제
입력
입력을 여러 줄로 이루어져 있다. 각 줄에 N이 주어진다. 파일의 끝에서 입력을 멈춘다. N은 0보다 크거나 같고, 12보다 작거나 같은 정수이다.
출력
입력으로 주어진 N에 대해서, 해당하는 칸토어 집합의 근사를 출력한다.
3의 n-1승이 공백의 크기로 전체 길이에서 빼주면 된다.
void cantor(int n)
{
int size = pow(3, n - 1);
if (n == 0)
{
cout << "-";
return;
}
cantor(n - 1);
for (int i = 0; i < size; i++)
{
cout << " ";
}
cantor(n - 1);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
while (cin >> n)
{
cantor(n);
cout << "\n";
}
return 0;
}