import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int n=in.nextInt();
int a[][]=new int[n][n];
for(int i=0;i<n-1;i++) {
int cnt=i+1;
for(int j=0;j<n-1;j++) {
a[i][j]=cnt;
if(cnt==n-1)cnt=1;
else cnt++;
}
}
for(int i=0;i<n;i++) {
a[i][n-1]=a[n-1][i]=a[i][i];
a[i][i]=0;
}
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++)
out.print(a[i][j]+" ");
out.println();
}
out.flush();
}
}
思路:使每