用数组存储,节省计算时间。时间复杂度n^2
#include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n, n){
int a[n][n];
double temp=0.5;
for(int i=0; i<n; i++){
a[i][0]=temp*2;
temp=a[i][0];
cout<<a[i][0]<<' ';
for(int j=1; j<n; j++){
a[i][j]=a[i][j-1]*2;
cout<<a[i][j]<<' ';
}
cout<<endl;
}
cout<<endl;
}
return 0;
}