#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
char map[1600][2600];
int a[15];
int n;
void draw(int x, int y, int n) {
if (n == 1) {
map[x][y + 1] = '/';
map[x][y + 2] = '\\';
map[x + 1][y] = '/';
map[x + 1][y + 1] = '_';
map[x + 1][y + 2] = '_';
map[x + 1][y + 3] = '\\';
return;
}
draw(x, y + a[n - 1], n - 1);
draw(x + a[n - 1], y, n - 1);
draw(x + a[n - 1], y + a[n], n - 1);
return;
}
int main() {
a[0] = 1;
for (int i = 1; i <= 13; ++i) {
a[i] = 2*a[i-1];
}
while (scanf("%d", &n) == 1) {
memset(map, ' ', sizeof(map));
if (n == 0)
break;
draw(0, 0, n);
for (int i = 0; i < a[n]; ++i) {
for (int j = 0; j < a[n+1]; ++j) {
printf("%c", map[i][j]);
}
printf("\n");
}
puts("");
}
return 0;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交