diff --git a/src/Lab2.java b/src/Lab2.java index f209094..5302f88 100644 --- a/src/Lab2.java +++ b/src/Lab2.java @@ -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; }