This commit is contained in:
Oleksii Aleshchenko 2023-04-06 15:34:03 +03:00
parent 9ece98fece
commit a61c59bf48
1 changed files with 8 additions and 0 deletions

View File

@ -99,12 +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 valueRepeats = 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];
valueRepeats = false;
} else if (MATRIX_C[i][j] == tmpSmallest) {
valueRepeats = true;
} }
} }
sum += tmpSmallest; sum += tmpSmallest;
if (!valueRepeats) {
sum += tmpSmallest;
}
} }
return sum; return sum;
} }