distributed-computing/tasks/klementeva-ja/lab_5/RVIP_Lab5/Alg1.cs

35 lines
867 B
C#
Raw Normal View History

2023-12-16 11:48:57 +04:00
namespace RVIP_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;
}
}
}