class Matriz { public static void main(String R[]) { Matriz2 M2 = new Matriz2(); M2.Inicia(); } } class Matriz2 { void Inicia() { // Se solicita la dimension de las matrices int R = Integer.parseInt(Lectura.LeeDato("Renglones: ")); int C = Integer.parseInt(Lectura.LeeDato("Columnas: ")); /* Se declaran las 3 matrices y se dimensionan */ int M1[][] = new int[R][C]; M1 = LlenaMatriz(M1); int M2[][] = new int[R][C]; M2 = LlenaMatriz(M2); int MR[][] = new int[R][C]; Muestre(M1); // Mostrar M1 Muestre(M2); // Mostrar M2 MR = Sume(M1, M2); // Se invoca la suma Muestre(MR); // Mostrar el resultado //int Max = ObtenMaximo(MR); // Obtener el valor mas grande //int Min = ObtenMinimo(MR); // Obtener el valor mas pequneo //Muestre(Max, Min); // Mostrar los valores extremos } int[][] LlenaMatriz(int M[][]) { for (int r = 0; r < M.length; r++) for (int c = 0; c < M[0].length; c++) M[r][c] = Integer.parseInt(Lectura.LeeDato("M["+r+","+c+"]= ")); return M; } void Muestre(int M[][]) { for (int r = 0; r < M.length; r++) for (int c = 0; c < M[0].length; c++) System.out.println("M["+r+","+c+"]= "+ M[r][c]); } int[][] Sume(int M1[][], int M2[][]) { int MR[][] = new int [M1.length][M1[0].length]; for (int r = 0; r < M1.length; r++) for (int c = 0; c < M1[0].length; c++) MR[r][c] = M1[r][c] + M2[r][c]; return MR; } }