错误代码样例:
#include<iostream>
using namespace std;
int main()
{
int n;
int arr[101][101]={0};
while(cin>>n,n)
{
for(int i=0;i<n;i++)
{
arr[i][i]=1;
for(int j=i+1,k=2;j<n;j++,k++)
{
arr[i][j]=k;
arr[j][i]=k;
}
for(int j=0;j<n;j++)
{
cout<<arr[i][j]<<' ';
//注意不能写成cout<<' '<<arr[i][j];
}
cout<<endl;
}
cout<<endl;
}
return 0;
}
作者:CSQN
链接:https://www.acwing.com/activity/content/code/content/9786412/
来源:AcWing