C#:
using System;
public class MatrixMult {
public static void Main() {
MultiplyMatrix();
}
public static void MultiplyMatrix() {
var a = new [, ] {
{5,10,13,-4,10},
{20,2,9,9,-1},
{5,10,4,8,14},
{6,1,2,6,10},
{95,5,10,10,2}};
var b = new [, ] {
{5,10,8,-4,62},
{20,2,9,9,-1},
{5,10,1,8,1},
{6,1,2,6,-5},
{95,5,1,3,2}};
var c = new [, ] {
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}};
for (int i = 0; i < c.GetLength(0); i++) {
for (int k = 0; k < c.GetLength(1); k++) {
for (int j = 0; j < a.GetLength(1); j++) {
c[i, k] += a[j, k] * b[i, j];
}
Console.Write("{0} ", c[i, k]);
}
Console.WriteLine();
}
Console.ReadKey();
}
}
Результат по выполнении:
6131 456 799 730 236
144 298 322 54 412
373 93 185 136 136
-379 63 57 -13 137
788 983 1310 -289 993
Нужно такой результат:
25 100 104 16 620
400 4 81 81 1
25 100 4 64 14
36 1 4 36 -50
9025 25 10 30 4