You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
636 B

#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int a[N][N];
void cal(int x, int y, int n) {
if (n == 0) a[x][y] = 1;
else {
cal(x + (1 << (n - 1)), y, n - 1);//左下角
cal(x, y + (1 << (n - 1)), n - 1);//右上角
cal(x + (1 << (n - 1)), y + (1 << (n - 1)), n - 1);//右下角
}
}
int main() {
int n;
cin >> n;
//开始计算最大的矩阵
cal(0, 0, n);
//输出
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < (1 << n); j++)
printf("%d%c", a[i][j], ' ');
printf("\n");
}
return 0;
}