Title: Enter a m*n order matrix to find the maximum value of the second order matrix in the M*n matrix
Input Sample:
1 2 3 0 4;4 3 5 1 2;3 2 4 7 5
Sample output:
17
------------------------------------------------I am a dividing line---------------------------------------------
Java code:
Import java.util.scanner;/** * 2*2-order matrix and maximum value in M*n-order matrix * * @author foreverlover * */public class Matrix {public static void Main (string[] args) {Scanner scan = new Scanner (system.in); int m;int n; String s = scan.nextline (); string[] sa = S.split (";"); m = sa.length; string[][] ss = new String[m][];for (int i = 0; i < m; i++) ss[i] = Sa[i].split (""); n = ss[0].length;int[][] array = NE W int[m][n];for (int i = 0; i < m; i++) {for (int j = 0; J < N; j + +) {Array[i][j] = Integer.parseint ((ss[i][j));}} int max = 0;for (int i = 0; i < m-1; i++) {int sum = 0;for (int j = 0; J < N-1; J + +) {sum = Array[i][j] + array[ I][j + 1] + array[i + 1][j]+ array[i + 1][j + 1];max = Sum >= max? Sum:max;}} SYSTEM.OUT.PRINTLN (max);}}
JAVA, finding the maximum value of 2*2 order matrix in M*n order matrix