distributed-computing/tasks/melnikov-ky/lab_5/Lab5/Alg1.cs

35 lines
862 B
C#
Raw Permalink Normal View History

2023-12-18 16:46:40 +04:00
namespace Lab5
{
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;
}
}
}