Răspuns:
#include <iostream>
using namespace std;
int main()
{
int a[20][20],i,j,n;
cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(i==j)
a[i][j]=0;
else
a[i][j]=n+1-j;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}
Explicație: