suggestion for lab2
This commit is contained in:
parent
9ece98fece
commit
32545562f8
|
@ -3,7 +3,7 @@ public class Lab2 {
|
||||||
final int A = 2;
|
final int A = 2;
|
||||||
final int[][] MATRIX_B = {
|
final int[][] MATRIX_B = {
|
||||||
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
|
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
|
||||||
{1, 202, 1, 1, 202, 3, 1, 202, 3, 4},
|
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
|
||||||
{1, 1, 3, 1, 202, 3, 1, 202, 3,},
|
{1, 1, 3, 1, 202, 3, 1, 202, 3,},
|
||||||
// {4, 5, 6,},
|
// {4, 5, 6,},
|
||||||
};
|
};
|
||||||
|
@ -99,13 +99,20 @@ public class Lab2 {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int j = 0; j < MATRIX_C[0].length; j++) {
|
for (int j = 0; j < MATRIX_C[0].length; j++) {
|
||||||
int tmpSmallest = MATRIX_C[0][j];
|
int tmpSmallest = MATRIX_C[0][j];
|
||||||
|
boolean value_repeats = false;
|
||||||
for (int i = 1; i < MATRIX_C.length; i++) {
|
for (int i = 1; i < MATRIX_C.length; i++) {
|
||||||
if (MATRIX_C[i][j] < tmpSmallest) {
|
if (MATRIX_C[i][j] < tmpSmallest) {
|
||||||
tmpSmallest = MATRIX_C[i][j];
|
tmpSmallest = MATRIX_C[i][j];
|
||||||
|
value_repeats = false;
|
||||||
|
} else if (MATRIX_C[i][j] == tmpSmallest) {
|
||||||
|
value_repeats = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!value_repeats) {
|
||||||
sum += tmpSmallest;
|
sum += tmpSmallest;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue