案例
请用二位数组输出如下图型
0 0 0 0 0 0 0
0 0 2 0 0 0 0
0 0 0 0 3 0 0
0 1 0 0 0 4 0
//细节: 定义上二维数组 [][] 来表示比如
int[][] arrs = {{0, 0, 0, 0, 0, 0, 0 },{0, 0, 2, 0, 0, 0, 0, },{0, 0, 0,0, 3, 0, 0},{0, 1, 0, 0, 0, 4, 0 }};
public class DimensionalArray{
public static void main(String[] args){
int arrs[][] = {{0, 0, 0, 0, 0, 0, 0 },{0, 0, 2, 0, 0, 0, 0, },{0, 0, 0,0, 3, 0, 0},{0, 1, 0, 0, 0, 4, 0 }};
for(int i = 0; i < arrs.length;i++){
for(int j = 0; j < arrs[i].length;j++){
System.out.print(arrs[i][j] + " ");
}
System.out.println(" ");
}
}
}