import java.util.Arrays;
class Homework3
{
public static void main(String[] args)
{
int arr1[][]= new int[6][6];
int i,j;
for(i = 0;i<6;i++){
for (j = 0;j<6;j++){
if (i == j){
arr1[i][j] = 5;
}
else if (i == j-1 || i == j+5){
arr1[i][j] = 7;
}
else if (i == j-2 || i == j+4){
arr1[i][j] = 4;
}
else if (i == j-3 || i == j+3){
arr1[i][j] = 8;
}
else if (i == j-4 || i == j+2){
arr1[i][j] = 9;
}
else if(i == j-5 || i == j+1){
arr1[i][j] = 1;
}
}
}
System.out.println("方阵为:");
for(i = 0;i < arr1.length;i++){
for(j = 0;j < arr1[i].length;j++){
System.out.print(arr1[i][j] + " ");
}
System.out.println();
}
}
}
输出结果为: