/*
* Copyright (c) 1999-2002, Xiaoping Jia.
* All Rights Reserved.
*/
/**
* This program finds the max-min value of a two-dimentioanl array.
*/
public class MaxMin {
public static void main(String[]args) {
double mat[][] = { { 2.3, 5.1, 9.9 },
{ 8.3, 4.5, 7.7 },
{ 5.2, 6.1, 2.8 } };
int n = mat.length;
int m = mat[0].length;
double maxmin = 0.0;
for (int j = 0; j < m; j++) {
double min = mat[j][0];
for (int i = 1; i < n; i++) {
min = Math.min(min, mat[i][j]);
}
if (j == 0) {
maxmin = min;
} else {
maxmin = Math.max(maxmin, min);
}
}
System.out.println("The max-min value is " + maxmin);
}
}