From a61c59bf483a09538c10f690e4ab98512b868196 Mon Sep 17 00:00:00 2001 From: Oleksii Aleshchenko Date: Thu, 6 Apr 2023 15:34:03 +0300 Subject: [PATCH] upd lab2 --- src/Lab2.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Lab2.java b/src/Lab2.java index f209094..f89087c 100644 --- a/src/Lab2.java +++ b/src/Lab2.java @@ -99,12 +99,20 @@ public class Lab2 { int sum = 0; for (int j = 0; j < MATRIX_C[0].length; j++) { int tmpSmallest = MATRIX_C[0][j]; + boolean valueRepeats = false; for (int i = 1; i < MATRIX_C.length; i++) { if (MATRIX_C[i][j] < tmpSmallest) { tmpSmallest = MATRIX_C[i][j]; + valueRepeats = false; + } else if (MATRIX_C[i][j] == tmpSmallest) { + valueRepeats = true; } } sum += tmpSmallest; + + if (!valueRepeats) { + sum += tmpSmallest; + } } return sum; }