本帖最后由 liyanghml 于 2015-3-27 22:27 编辑
你想怎么快呢,按照数组遍历不好吗(希望能帮到你)class GetmaxDemo
{
public static void main(String[] args)
{
int [][]arr = {{2,1,4,-7},{-13,3,5,6},{121,-21,9,14}};
int max = getMax(arr);
System.out.println(max);
}
public static int getMax(int[][] arr)
{
int tem =0,tem1=0;
for(int x = 0;x<arr.length;x++)
{
for(int y =0;y<arr[x].length;y++)
if(arr[x][y]>arr[tem][tem1])
{
tem1 = y;
tem = x;
}
}
return arr[tem][tem1];
}
|