螺旋矩阵
public static void juz(){
int i = 1;
int n = 10;
int l = 0, h = 0;
boolean right = true;
boolean down = false;
boolean left = false;
boolean up = false;
int[][] a = new int[n][n];
while(i < n * n){
if(right){
if(l<n || a[h][l] == 0){
a[h][l++] = i++;
}
if(l == n || a[h][l] > 0){
l--;
h++;
right = false;
down = true;
}
}
if(down){
if(h<n || a[h][l] == 0){
a[h++][l] = i++;
}
if(h == n || a[h][l] > 0){
h--;
l--;
down = false;
left = true;
}
}
if(left){
if(l>=0 || a[h][l] == 0){
a[h][l--] = i++;
}
if(l < 0 || a[h][l] > 0){
h--;
l++;
left = false;
up = true;
}
}
if(up){
if(a[h][l] == 0){
a[h--][l] = i++;
}
if(a[h][l] > 0){
h++;
l++;
up = false;
right = true;
}
}
}
for(int b = 0; b < a.length; b++){
for(int c = 0; c < a[b].length; c++){
System.out.printf("%3d", a[b][c]);
}
System.out.println();
}
}