第1个回答 2014-09-12
public class Test {
public static void main(String[] args){
//定义矩阵
int[][] a =new int[][]{{1,2,3,4},{12,22,3388,44},{51,62,3776,4},{18,2,73,4},{1,26,35,448}};
//记录行好和列号
int h=0;
int l=0;
for(int i=0;i<5;i++){
for(int j=0;j<4;j++){
if(a[h][l]<a[i][j]){
h=i;
l=j;
}
}
}
//因为Java中的数组索引时从0开始的,与数学中矩阵不一样,需要加1
System.out.println("最大值:"+a[h][l]+" 行号为"+(h+1)+" 列号为"+(l+1));
}
}
第2个回答 2014-09-12
public class MaxInMatrix {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[][] arr={{1,3,4,5},{3,2,5,23},{324,54,323,32},{232,343,2,3212},{1,4,5,3430}};
int max=arr[0][0];
int col=0;
int row=0;
for(int i=0;i<5;i++)
for(int j=0;j<4;j++){
if(arr[i][j]>max){
max=arr[i][j];
col=j+1;
row=i+1;
}
}
System.out.println("最大:"+max+"行:"+row+"列:"+col);
}
随便写的,你可以改造一下本回答被网友采纳
第3个回答 2014-09-12
int a[][] = new int[5][4];
//a赋值略
int max = a[0][0];
int x = 0;
int y = 0;
for(int i=0;i<a.length;i++){
for(int j=0;i<a[i].length;j.++){
if(max < a[i][j]){
max = a[i][j];
x = i;
y = j;
}
}
}
System.out.println("最大值为:" + max + "坐标为:"+x+":"+y);
第4个回答 2014-09-12
int x = 0;
int y = 0;
int max = 0;
int[][] a = new int[5][4];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
a[i][j] = ((int)(1+Math.random()*100000));
System.out.println("第"+i+"行 " + j +"列值为:"+ a[i][j]);
if(a[i][j] > max){
max = a[i][j] ;
x = i;
y = j;
}
}
}
System.out.println("最大值为:"+max +"在第"+x+"行"+y+"列");