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
|
#include <iostream>
using namespace std;
//const int SIZE = 100;
//typedef double Matrix[SIZE][SIZE];
void multiply(double a[5][2], double b[5][2], double c[5][2], int n)
{
int i, j, k;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
c[i][j] = 0;
for (k = 0; k < n; k++)
c[i][j] += a[i][k] * b[k][j];
}
}
int main()
{
double matrix1[5][2]={{1,2},
{4,5},
{7,8},
{2,4},
{3,6}};
double matrix2[5][2]={ {10,11},
{13,14},
{16,17},
{19,20},
{23,25}};
double matrix3[5][2] ={{0,0},
{0,0},
{0,0},
{0,0},
{0,0}};
multiply(matrix1,matrix2,matrix3,10);
cout <<matrix3[0][0]<<endl;
}
|