反对角线相等:每条反对角线上,坐标之和是相等的!可以找 数 和坐标的关系
正对角线相等:可以每次从$对角线上的点$开始向 $右$ 和 $下$ 一起遍历
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int q[200][200];
int n;
while(cin >> n, n)
{
for (int i = 0; i < n; i ++ )
for (int j = 0; j < n; j ++ )
{
q[i][j] = 1;
for (int k = 0; k < i + j; k ++ ) q[i][j] *= 2;
}
for (int i = 0; i < n; i ++ )
{
for (int j = 0; j < n; j ++ ) cout << q[i][j] << ' ';
cout << endl;
}
cout << endl;
}
return 0;
}
y总太棒了!
看坐标与数的关系(dl的做法
int n;
while(cin >> n, n)
{
for (int i = 0; i < n; i ++ )
{
for (int j = 0; j < n; j ++ )
cout << (1 << i) * (1 << j) << ' ';
cout << endl;
}
cout << endl;
}