求助,我的代码是在其他在线编程网站写的,代码如下
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;int m=1;int ci[11];
cin>>n;
for(int i=1;i<=n;i++){
m*=2;
ci[i]=m;
}
int a[1025][1025];
a[1024][1]=1;a[1023][1]=0;a[1024][2]=1;a[1023][2]=1;
for(int h=1;h<=n-1;h++){
for(int i=1;i<=ci[h];i++){
for(int x=1024;x>=1025-ci[h];x--){
for(int y=1;y<=ci[h];y++){
a[x][y+ci[h]]=a[x][y];
a[x-ci[h]][y+ci[h]]=a[x][y];
a[x-ci[h]][y]=0;
}
}
}
}
for(int y=1;y<=m;y++){
for(int x=1025-m;x<=1024;x++){
cout<<a[x][y]<<' ';
if(x==1024){
cout<<endl;
}
}
}
}