anoterCode
This commit is contained in:
parent
2ef62c7887
commit
922420d5e2
@ -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);
|
||||
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 i = 0; i < M.length; i++) {
|
||||
System.out.println("");
|
||||
for (int j = 0; j < M[i].length; j++) {
|
||||
System.out.print(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 (M[i][j] < temp) {
|
||||
temp = M[i][j];
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user