#include <iostream>
#include <vector>
using namespace std;
void multiply(vector< vector<double> > a, vector< vector<double> > b, vector< vector<double> >& c);
int main()
{
cout << 'A' << endl;
vector< vector<double> > a;
vector<double> temp;
temp.push_back(11);
temp.push_back(12);
temp.push_back(13);
temp.push_back(14);
temp.push_back(15);
a.push_back(temp);
temp.clear();
temp.push_back(21);
temp.push_back(22);
temp.push_back(23);
temp.push_back(24);
temp.push_back(25);
a.push_back(temp);
temp.clear();
temp.push_back(31);
temp.push_back(32);
temp.push_back(33);
temp.push_back(34);
temp.push_back(35);
a.push_back(temp);
temp.clear();
for (int i = 0;i<=2;i++)
{
for (int j = 0;j<=4;j++)
cout << a[i][j] << '\t';
cout << endl;
}
cout << 'B' << endl;
vector< vector<double> > b;
temp.push_back(11);
temp.push_back(12);
temp.push_back(13);
temp.push_back(14);
b.push_back(temp);
temp.clear();
temp.push_back(21);
temp.push_back(22);
temp.push_back(23);
temp.push_back(24);
b.push_back(temp);
temp.clear();
temp.push_back(31);
temp.push_back(32);
temp.push_back(33);
temp.push_back(34);
b.push_back(temp);
temp.clear();
temp.push_back(41);
temp.push_back(42);
temp.push_back(43);
temp.push_back(44);
b.push_back(temp);
temp.clear();
temp.push_back(51);
temp.push_back(52);
temp.push_back(53);
temp.push_back(54);
b.push_back(temp);
temp.clear();
for (int i = 0;i<=4;i++)
{
for (int j = 0;j<=3;j++)
cout << b[i][j] << '\t';
cout << endl;
}
cout << 'C' << endl;
vector< vector<double> > c(3, vector<double>(4, 0));
multiply(a,b,c);
for (int i = 0;i<=2;i++)
{
for (int j = 0;j<=3;j++)
cout << c[i][j] << '\t';
cout << endl;
}
return 0;
}
void multiply(vector< vector<double> > a, vector< vector<double> > b, vector< vector<double> >& c)
{
int i, j, k;
double s;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
s = 0;
for (k = 0; k < 5; k++)
s += a[i][k] * b[k][j];
c[i][j] = s;
}
}
}
A
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
B
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
51 52 53 54
C
2115 2180 2245 2310
3665 3780 3895 4010
5215 5380 5545 5710