#include <iostream>
#include <iomanip>
using namespace std;
class Matrix
{
private:
int m[2][2],i,j;
public:
void read()
{
for(i=0;i<2;i++)
for(j=0;j<2;j++)
cin>>m[i][j];
}
void display()
{
#include <iomanip>
using namespace std;
class Matrix
{
private:
int m[2][2],i,j;
public:
void read()
{
for(i=0;i<2;i++)
for(j=0;j<2;j++)
cin>>m[i][j];
}
void display()
{
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
cout<<m[i][j]<<setw(2);
cout<<endl;
}
}
friend Matrix operator*(Matrix a,Matrix b)
{
int i,j,k,sum=0;
Matrix c;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
cout<<m[i][j]<<setw(2);
cout<<endl;
}
}
friend Matrix operator*(Matrix a,Matrix b)
{
int i,j,k,sum=0;
Matrix c;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
for(k=0;k<2;k++)
{
sum=sum+a.m[i][k]*b.m[k][j];
}
c.m[i][j]=sum;
sum=0;
}
}
return c;
{
for(k=0;k<2;k++)
{
sum=sum+a.m[i][k]*b.m[k][j];
}
c.m[i][j]=sum;
sum=0;
}
}
return c;
No comments:
Post a Comment