C++ 代码
#include <iostream>
using namespace std;
const int N = 110;
int a[N][N];
int main()
{
int n;
while(cin >> n, n)
{
for(int i = 1; i <= n; i ++)
{
for(int j = i,k = 1; j <= n; j ++,k ++)
{
a[i][j] = k; //一行一列输入
a[j][i] = k;
}
}
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= n; j ++)
cout << a[i][j] << ' ';
cout << endl;
}
cout << endl;
}
return 0;
}