题目链接:
http://poj.org/problem?id=2083
题目描述:
n = 1时,图形b[1]是X
n = 2时,图形b[2]是X X
X
X X
所以n时,图形b[n]是b[n-1] b[n-1]
b[n-1]
b[n-1] b[n-1]
解题思路:
用递归打印图形,存到二维数组里面,输出是一个矩形,竟然是一个矩形!!!!!!
代码:
1 #include <cmath> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 using namespace std; 6 #define maxn 740 7 char map[maxn][maxn]; 8 9 void dfs (int n, int x, int y); 10 //n是b[n],(x,y)是b[n]左上那个点; 11 int main () 12 { 13 int i, j, n; 14 while (scanf ("%d", &n), n != -1) 15 { 16 int m = (int)pow(3,n-1); 17 for (i=0; i<=m; i++) 18 { 19 for (j=0; j<=m; j++) 20 map[i][j] = ' '; 21 map[i][m+1] = '