From 922420d5e28e86fc6cc7e48f8501010bfcf2c742 Mon Sep 17 00:00:00 2001 From: dadgam3er Date: Wed, 11 Sep 2024 23:19:05 -0400 Subject: [PATCH] anoterCode --- MinMatrix.java | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/MinMatrix.java b/MinMatrix.java index 88f9256..f3d533d 100644 --- a/MinMatrix.java +++ b/MinMatrix.java @@ -3,22 +3,41 @@ */ public class MinMatrix { public static void main(String[] args) { - int[][] M = { { 31, 53, 65 }, { 23, 86, 99 }, { 5, 45, 66 } }; - int temp = M[0][0]; - System.out.println("This is the matrix memory allocation"); - System.out.println(M); - System.out.println(""); - for (int i = 0; i < M.length; i++) { + int[][] morpheous = { { 13, 53, 47 }, { 32, 53, 87 }, { 86, 43, 74 } }; + int temp = morpheous[0][0]; + int matrixMax = 0; + int z = 0; + int max = 0; + String str = ""; + for (int i = 0; i < morpheous.length; i++) { System.out.println(""); - for (int j = 0; j < M[i].length; j++) { - System.out.print(M[i][j]); - System.out.print("\t"); - if (M[i][j] < temp) { - temp = M[i][j]; + for (int k = 0; k < morpheous[i].length; k++) { + System.out.print(morpheous[i][k]); + if (morpheous[i][k] > matrixMax) { + matrixMax = morpheous[i][k]; } + System.out.print("\t"); + if (morpheous[i][k] < temp) { + temp = morpheous[i][k]; + z = k; + } + if (morpheous[i][z] > max) { + max = morpheous[i][z]; + } + } } + if (z == 0) { + str = "first"; + } else if (z == 1) { + str = "second"; + } else { + str = "thrid"; + } System.out.println(""); - System.out.println("The smallest number in this Matrix is: " + temp); + System.out.println("the largest number in the morpheous Matrix is: " + matrixMax); + System.out.println("The smallest number in the matrix is: " + temp + " in the " + str + " column!"); + System.out.println("The largest number in the same column is: " + max); + } }