#include <iostream>
void Multiply(float N[4][4], float M[4][4], float Result[4][4])
{
for (int I = 0; I < 4; ++I)
{
for (int J = 0; J < 4; ++J)
{
double SumElements = 0.0;
for (int K = 0; K < 4; ++K)
{
SumElements += M[I][K] * N[K][J];
}
Result[I][J] = SumElements;
}
}
}
void Print(float mat[4][4])
{
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
std::cout<<mat[i][j]<<" ";
}
std::cout<<"\n";
}
}
int main()
{
float N[4][4] =
{
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16}
};
float M[4][4] =
{
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16}
};
float Result[4][4];
Multiply(N, M, Result);
Print(Result);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdm9pZCBNdWx0aXBseShmbG9hdCBOWzRdWzRdLCBmbG9hdCBNWzRdWzRdLCBmbG9hdCBSZXN1bHRbNF1bNF0pCnsKICAgIGZvciAoaW50IEkgPSAwOyBJIDwgNDsgKytJKQogICAgewogICAgICAgIGZvciAoaW50IEogPSAwOyBKIDwgNDsgKytKKQogICAgICAgIHsKICAgICAgICAgICAgZG91YmxlIFN1bUVsZW1lbnRzID0gMC4wOwogICAgICAgICAgICBmb3IgKGludCBLID0gMDsgSyA8IDQ7ICsrSykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgU3VtRWxlbWVudHMgKz0gTVtJXVtLXSAqIE5bS11bSl07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgUmVzdWx0W0ldW0pdID0gU3VtRWxlbWVudHM7CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIFByaW50KGZsb2F0IG1hdFs0XVs0XSkKewoJZm9yIChpbnQgaSA9IDA7IGkgPCA0OyArK2kpCgl7CgkJZm9yIChpbnQgaiA9IDA7IGogPCA0OyArK2opCgkJewoJCQlzdGQ6OmNvdXQ8PG1hdFtpXVtqXTw8IiAiO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