算法1
ltk小姐姐找的这个规律很巧妙
C++ 代码
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main()
{
while (cin >> n)
{
for (int i = 0; i < n; i ++ )
{
for(int j = 0; j < n; j ++ )
cout << abs(i - j) + 1 << ' '; // 规律
cout << endl;
}
if (n) cout << endl;
}
return 0;
}