distributed-computing/tasks/grenaderova-aa/lab_5/5LABA/Alg1.cs
2023-12-18 16:34:36 +04:00

35 lines
863 B
C#

namespace 5LABA
{
public class Alg1
{
static int[,] MultiplyMatrices(int[,] matrix1, int[,] matrix2)
{
int rows1 = matrix1.GetLength(0);
int cols1 = matrix1.GetLength(1);
int cols2 = matrix2.GetLength(1);
int[,] result = new int[rows1, cols2];
for (int i = 0; i < rows1; i++)
{
for (int j = 0; j < cols2; j++)
{
for (int k = 0; k < cols1; k++)
{
result[i, j] += matrix1[i, k] * matrix2[k, j];
}
}
}
return result;
}
public int[,] Begin(int[,] matrix1, int[,] matrix2)
{
int[,] result = MultiplyMatrices(matrix1, matrix2);
return result;
}
}
}