提交时间:2019-11-13 18:40:44
运行 ID: 2224
#include<iostream> #include<iomanip> using namespace std; const int N = 1050; int a[N][N]; int main(){ int m,n,half; cin>>m; n=1<<m,half=1; a[0][0]=1; while (m--){ for (int i=0; i<half; i++) for (int j=0; j<half; j++) a[i][j+half]=a[i][j]+half; //构造右上方 for (int i=0; i<half; i++) for (int j=0; j<half; j++){ a[i+half][j]=a[i][j]+half; //构造左下方 a[i+half][j+half]=a[i][j]; //构造右下方 } half*=2; } for (int i=0; i<n; i++){ for (int j=0; j<n; j++) cout<<setw(3)<<a[i][j]; cout<<endl; } return 0; }