二维数组根据其下标,判断它是第几个元素
3 3
0 2 2
1 2 1
2 2 1
public class qqqq {
static int row;
static int col;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
row = in.nextInt();
col = in.nextInt();
int[][] arr = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.println("这是第 " + (i * col + j) + "个元素");
arr[i][j] = in.nextInt();
}
}
}
}
标签:下标,第几个,int,nextInt,static,col,row
From: https://www.cnblogs.com/aclq/p/17792715.html