日期:2014-05-20  浏览次数:20832 次

二维数组程序
用JAVA编一个程序  
找出二维数组的鞍点,即该位置上的元素在该行上最大,在该列上最小,也可能没有鞍点.

------解决方案--------------------
你要多大的二维数组,请说的具体点。
------解决方案--------------------
public class Test
{
public static final int N=4;

public static boolean find(int[][] array){
boolean finded=false;
for(int i=0;i <N;i++){
int rowMax=array[i][0];
int col=0;
for(int j=1;j <N;j++){
if(array[i][j]> rowMax){
rowMax=array[i][j];
col=j;
}
}
int j;
for(j=0;j <N;j++){
if(array[j][col] <rowMax)
break;
}
if(j> =N){
System.out.println( "find the point: col= "+col+ ",row= "+i);
return true;
}
}
return false;
}

public static void main(String[] args){
int[][] array={{10,100,5,2},
{1,65,6,4},
{17,261,2,58},
{23,66,30,4} };
if(!find(array))
System.out.println( "not found ");
}
};

没分下书了,来赚点分