题目链接:http://acm.henu.edu.cn/contest/problem?id=2&pid=5
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e1 + 5;
char Graph[maxn][maxn];
void Fractal(int N, int X, int Y) {
if (N == 1) {
Graph[X][Y] = 'o';
return;
}
int Size = pow(2, N - 2);
Fractal(N - 1, X, Y + Size);
Fractal(N - 1, X + Size, Y);
Fractal(N - 1, X + Size, Y + Size);
}
int main(int argc, char *argv[]) {
int N;
while (~scanf("%d", &N) && N) {
int Size = pow(2, N - 1);
memset(Graph, ' ', sizeof(Graph));
Fractal(N, 0, 0);
for (int i = 0; i < Size; ++i) {
for (int j = 0; j < Size; ++j) {
printf("%c", Graph[i][j]);
}
printf("\n");
}
}
return 0;
}