#include <iostream>
using namespace std;
int main()
{
int i,j,k;
int Matrix1[3][3] = {
{1,2,3},
{4,5,6},
{1,2,3},
};
int Matrix2[3][3] = {
{3,2,1},
{6,5,4},
{3,2,1},
};
int Matrix3[3][3];
cout << "Matrix 1: " << endl;
for( i = 0; i < 3; i++)
{
for( j = 0; j < 3; j++)
{
cout << " " << Matrix1[i][j];
}
cout << endl;
}
cout << endl;
cout << "Matrix 2: " << endl;
for( i = 0; i < 3; i++)
{
for( j = 0; j < 3; j++)
{
cout << " " << Matrix2[i][j];
}
cout << endl;
}
cout << endl;
for(i = 0; i < 3; i++)
{
for( j = 0; j < 3; j++)
{
for( k = 0; k < 3; k++)
{
Matrix3[i][j] += Matrix1[i][k]*Matrix2[k][j];
}
}
}
cout << "Matrix 3: " << endl;
for( i = 0; i < 3; i++)
{
for( j = 0; j < 3; j++)
{
cout << " " << Matrix3[i][j];
}
cout << endl;
}
cout << endl;
return 0;
}
shandow -3 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.