Created
November 28, 2016 09:45
-
-
Save HyeonWooKim/f6aa83899f233a658251bdb5fe87470a to your computer and use it in GitHub Desktop.
BOJ 2447
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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