2483: 【普及-】【P1498】南蛮图腾

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

给定一个正整数 lns="http://www.w3.org/1998/Math/MathML">,参考输出样例,输出图形。

输入

每个数据输入一个正整数 lns="http://www.w3.org/1998/Math/MathML">,表示图腾的大小(此大小非彼大小)

输出

这个大小的图腾

样例输入 复制

2

样例输出 复制

   /\
  /__\
 /\  /\
/__\/__\

提示


#include<bits/stdc++.h>

using namespace std;
char c[2050][2050];
void f(int x, int y, int n) {
    if (n == 1) {
        c[x][y + 1] = '/';
        c[x + 1][y] = '/';
        c[x][y + 2] = '\\';
        c[x + 1][y + 3] = '\\';
        c[x + 1][y + 1] = '_';
        c[x + 1][y + 2] = '_';
        return;
    }
    int distance = pow(2, n);
    f(x, y + distance / 2, n - 1);
    f(x + distance / 2, y, n - 1);
    f(x + distance / 2, y + distance, n - 1);
}
main() {
    int n;
    cin >> n;
    memset(c, ' ', sizeof(c));
    f(0, 0, n);
    int distance = pow(2, n);
    for (int i = 0; i < distance; i++) {
        for (int j = 0; j < distance * 2; j++) {
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}