Skip to content

Instantly share code, notes, and snippets.

@HyeonWooKim
Created November 28, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HyeonWooKim/f6aa83899f233a658251bdb5fe87470a to your computer and use it in GitHub Desktop.
Save HyeonWooKim/f6aa83899f233a658251bdb5fe87470a to your computer and use it in GitHub Desktop.
BOJ 2447
#include<cstdio>
char s[3000][3000] = { 0 };
void dfs(int depth, int w, int h)
{
if (depth == 1)
{
s[w][h] = '*';
return;
}
int next = depth / 3;
for (int i = 0, x = w; i < 3; i++, x += next)
{
for (int j = 0, y = h; j < 3; j++, y += next)
{
if (i == 1 && j == 1) continue;
dfs(depth / 3, x, y);
}
}
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
s[i][j] = ' ';
dfs(n, 1, 1);
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++) printf("%c", s[i][j]);
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment