anoterCode
This commit is contained in:
parent
2ef62c7887
commit
922420d5e2
@ -3,22 +3,41 @@
|
|||||||
*/
|
*/
|
||||||
public class MinMatrix {
|
public class MinMatrix {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int[][] M = { { 31, 53, 65 }, { 23, 86, 99 }, { 5, 45, 66 } };
|
int[][] morpheous = { { 13, 53, 47 }, { 32, 53, 87 }, { 86, 43, 74 } };
|
||||||
int temp = M[0][0];
|
int temp = morpheous[0][0];
|
||||||
System.out.println("This is the matrix memory allocation");
|
int matrixMax = 0;
|
||||||
System.out.println(M);
|
int z = 0;
|
||||||
|
int max = 0;
|
||||||
|
String str = "";
|
||||||
|
for (int i = 0; i < morpheous.length; i++) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
for (int i = 0; i < M.length; i++) {
|
for (int k = 0; k < morpheous[i].length; k++) {
|
||||||
System.out.println("");
|
System.out.print(morpheous[i][k]);
|
||||||
for (int j = 0; j < M[i].length; j++) {
|
if (morpheous[i][k] > matrixMax) {
|
||||||
System.out.print(M[i][j]);
|
matrixMax = morpheous[i][k];
|
||||||
|
}
|
||||||
System.out.print("\t");
|
System.out.print("\t");
|
||||||
if (M[i][j] < temp) {
|
if (morpheous[i][k] < temp) {
|
||||||
temp = M[i][j];
|
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("");
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user