编译通过,运行时总报益处,找出这个程序哪有问题?
import java.util.Scanner;
public class JiuGong{
public static void main(String[]args){
Scanner s = new Scanner(System.in);
int x = s.nextInt();
int h = 0;
int l = x/2;
int[][] a = new int[x][x];
for(int i=1;i<=x*x;i++){
a[h][l] = i; //运行提示溢出
if(h==0&&l==x-1){h++;}
else if(h==0){h=x-1;l++;}
else if(l==x-1){h--;l=0;}
else if(a[--h][++l]!=0){h+=2;l--;}
else {h--;l++;}
}
for(int j=0;j<x;j++){
for(int k=0;k<x;k++){
System.out.print(a[h][l]+" ");
}
System.out.println();
}
}
}