public class Abc
{
public static void main(String[] args)
{
int[][] arr = { {1, 2, 3, 4}, {5, 6, -1, 8}, {9, 22, 11, 12}};
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int col_min = 0, row_min = 0;
int col_max = 0, row_max = 0;
for (int i = 0; i < arr.length; i++)
{
for (int j = 0; j < arr[i].length; j++)
{
if (arr[i][j] < min)
{
min = arr[i][j];
row_min = i;
col_min = j;
}
if (arr[i][j] > max)
{
max = arr[i][j];
row_max = i;
col_max = j;
}
}
}
System.out.println("最小数:" + min + ",行 = " + row_min + ", 列 =" + col_min);
System.out.println("最大数:" + max + ",行 = " + row_max + ", 列 =" + col_max);
}
}
温馨提示:内容为网友见解,仅供参考