백준 2447 c++
#include <iostream>
using namespace std;
void star(int N, int i, int j);
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N, i, j, temp;
//cin >> N;//3의 1승부터 7승 사이의 값
while (1)
{
cin >> N;
temp = N;
for (i = 1; i < 8; i++)
{
if (temp == 3)
{
break;
}
else if (temp % 3 == 0)
{
temp = temp / 3;
}
else
{
break;
}
}
if (temp == 3)
{
break;
}
else
{
;
}
}
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
star(N, i, j);
}
cout << "\n";
}
return 0;
}
void star(int N, int i, int j)
{
if (N == 1)
{
cout << "*";
}
else if (((i/(N/3))%3 == 1) && ((j/(N/3))%3 == 1))
{
cout << " ";
}
else
{
star(N / 3, i, j);
}
}