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[][] MATRIX_B = {
|
||||
{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,},
|
||||
// {4, 5, 6,},
|
||||
};
|
||||
|
@ -99,12 +99,19 @@ public class Lab2 {
|
|||
int sum = 0;
|
||||
for (int j = 0; j < MATRIX_C[0].length; j++) {
|
||||
int tmpSmallest = MATRIX_C[0][j];
|
||||
boolean value_repeats = false;
|
||||
for (int i = 1; i < MATRIX_C.length; i++) {
|
||||
if (MATRIX_C[i][j] < tmpSmallest) {
|
||||
tmpSmallest = MATRIX_C[i][j];
|
||||
value_repeats = false;
|
||||
} else if (MATRIX_C[i][j] == tmpSmallest) {
|
||||
value_repeats = true;
|
||||
}
|
||||
}
|
||||
sum += tmpSmallest;
|
||||
|
||||
if (!value_repeats) {
|
||||
sum += tmpSmallest;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue