#include <bits/stdc++.h>
using namespace std;
int a[110][110], n;
int main() {
cin >> n;
n = pow(2, n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == 1 || j == i) {
a[i][j] = 1;
} else {
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
}
}
for (int i = 1; i <= n; i++) {
for (int k = n - i; k >= 1; k--) {
cout << 0 << " ";
}
for (int j = 1; j <= i; j++) {
if (a[i][j] % 2 == 0 ) {
cout << 0 << " ";
} else {
cout << 1 << " ";
}
}
cout << endl;
}
return 0;
}
这道题跟杨辉三角很像,用杨辉三角代码改的,对了一部分