模拟题 while就完事了
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
int a[][]=new int [n][m];
int x=0;
int y=0;
int tot=2;
a[x][y]=1;
while(tot<=n*m) {
while(y+1[HTML_REMOVED]=0&&a[x][y-1]==0) {
y-=1;
a[x][y]=tot;
}
while(x-1>=0&&a[x-1][y]==0) {
x-=1;
a[x][y]=tot;
}
}
for(int i=0;i<n;i) {
for(int j=0;j<m;j) {
System.out.print(a[i][j]+” “);
}
System.out.println();
}
}
}