AcWing 754. 平方矩阵 II
原题链接
简单
作者:
Winkel
,
2021-02-06 18:24:13
,
所有人可见
,
阅读 341
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin >> n, n)
{
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
cout << abs(i - j) + 1 << ' ';
}
cout << endl;
}
cout << endl;
}
}
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin >> n, n)
{
for(int i = 1; i <= n; i++)
{
for(int j = i; j >= 1; j--) cout << j << ' '; //对角线及之前的
for(int j = i + 1; j <= n; j++) cout << j - i + 1 << ' '; //对角线之后的
cout << endl;
}
cout << endl;
}
}