#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;
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.