update lab2

This commit is contained in:
Oleksii Aleshchenko 2023-03-30 15:50:18 +03:00
parent f385bff73d
commit 399941844f
1 changed files with 8 additions and 6 deletions

View File

@ -2,10 +2,10 @@ public class Lab2 {
public static void main(String[] args) {
final int A = 2;
final int[][] MATRIX_B = {
{1, 202, 3,1, 202, 3,1, 202, 3,},
{202, 3,1, 202, 3,1, 202, 3,},
{3,1, 202, 3,1, 202, 3,},
{4, 5, 6,},
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
{1, 202, 1, 1, 202, 3, 1, 202, 3,},
{1, 1, 3, 1, 202, 3, 1, 202, 3,},
// {4, 5, 6,},
};
int[][] MATRIX_C = multiplication(A, MATRIX_B);
@ -63,11 +63,13 @@ public class Lab2 {
private static int sumOfSmallestElementsInEveryColumn(final int[][] MATRIX_C) {
// todo check different length of rows
// todo try to change i and j
// todo check repetition of minimal elements
int sum = 0;
for (int i = 0; i < MATRIX_C[0].length; i++) {
int tmpSmallest = MATRIX_C[0][i];
for (int j = 1; j < MATRIX_C.length; j++) {
if (tmpSmallest < MATRIX_C[j][i]) {
if (MATRIX_C[j][i] < tmpSmallest) {
tmpSmallest = MATRIX_C[j][i];
}
}