/**
* 6-1
* Write a program to find the saddle point of a two-dimensional array
*/
Import java.util.scanner;public class test{public static void main (String[] args) {/* Create a two-dimensional array */int i, j, k, l, m = 0, max, min, line= 0, list=0; Scanner read = new scanner (system.in); System.out.println ("Please enter rows and columns of two-dimensional arrays"); Line = read.nextint (); List = read.nextint ();int array[][] = new int[line][list]; System.out.println ("Enter the individual element values of the two-dimensional array");for (i = 0; i < line; i++) for ( j = 0; j < list; j++) Array[i][j] = read.nextint ();//int array[ ][]= new int[][]{{2,3,4,5,6},// {3,4,5,6,8},// {3,1,2,5,9},// {3,4,1,8,7}};//line=4;//list=5;/* looking for Saddle point */system.out.println ("Start looking for Saddle point ^_^");for (i = 0; i < line; i++) {max = array[i][0];k = 0;for (j = 1; j < list; j++) if (Array[i][j] > max) {max = array[i][j];k = j;} min = array[0][k];for (l = 1; l < line; l++) if (array[l][ K] < min) min = array[l][k];if (max == min) {System.out.println ("There is a saddle point in the " + i + " line, section " + (j-1) + " column, Value: "+array[i][j-1]); m++;}} if (m == 0) System.out.println ("There is no saddle point!");}}
Those years, learn together Java 6-1