using System using System Collections Generic using System Text namesp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication73
{
class Program
{
static double[,] mult(double[,] mat1, double[,] mat2)
{
double[,] matrix = new double[mat1.GetLength(0), mat2.GetLength(1)];
for (int i = 0; i <= mat1.GetLength(0)-1; i++)
{
for (int j = 0; j <= mat2.GetLength(1)-1; j++)
{
double a = 0;
for (int k = 0; k <= mat2.GetLength(0)-1; k++)
{
a = mat1[i, k] * mat2[k, j ] + a;
}
matrix[i, j] = a;
}
}
return matrix;
}
static void Main(string[] args)
{
double[,] mat1 = new double[3, 2]
{
{1,2},
{2,3},
{1,3}
};
double[,] mat2 = new double[2, 3]
{
{2,1,2},
{1,3,2}
};
double[,] matrix = mult(mat1, mat2);
}
}
}