[java]代码库
public class Search {
public static final int[][] array ={
{8,2,3,4,5},
{7,6,5,8,8},
{6,4,5,7,10}
};
public static void main(String[] args) {
for(int i=0;i<array.length;i++){
int minCol = getrowMin(i);
if(iscolMin(minCol,i)){
System.out.println("array["+i+"]["+minCol+"]");
}
}
}
public static int getrowMin(int rowNo){
int min=array[rowNo][0];
int col=0;
for(int i=1;i<array[rowNo].length;i++){
if(array[rowNo][i]<min){
min=array[rowNo][i];
col=i;
}
}
return col;
}
public static boolean iscolMin(int colNo,int rowNo){
for(int i=0;i<array.length;i++){
if(array[i][colNo]<array[rowNo][colNo])return false;
}
return true;
}
}