找规律
(找规律) $O(n^2)$
找到规律直接输出就行了
C++ 代码
#include <iostream>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
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;
}
return 0;
}