#include<conio.h>
#include<iostream.h>
class mt
{
private:
float a[3][3];
int i;
int j;
public:
void nhap()
{
cout<<"\n";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
cout<<"a["<<i<<"]["<<j<<"]: ";
cin>>a[i][j];
}
}
void hien()
{
for(i=0;i<3;i++)
{
cout<<"\n";
for(j=0;j<3;j++)
cout<<a[i][j]<<"\t";
}
}
mt operator+(mt x);
mt operator-(mt x);
mt operator*(mt x);
mt operator/(mt x);
};
mt mt::operator+(mt x)
{
mt s;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
s.a[i][j]=this->a[i][j]+x.a[i][j];
return s;
}
mt mt::operator-(mt x)
{
mt t;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
t.a[i][j]=this->a[i][j]-x.a[i][j];
return t;
}
mt mt::operator*(mt x)
{
mt u;
int k;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
u.a[i][j]=0;
for(k=0;k<3;k++)
u.a[i][j]=(this->a[i][k]*x.a[k][j])+u.a[i][j];
}
return u;
}
mt mt::operator/(mt x)
{
mt v;
int k;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
v.a[i][j]=0;
for(k=0;k<3;k++)
v.a[i][j]=(this->a[i][k]/x.a[k][j])+v.a[i][j];
}
return v;
}
int main()
{
mt b,c,s,t,u,v;
cout<<"nhap ma tran thu 1:";
b.nhap();
cout<<"\nma tran vua nhap:";
b.hien();
cout<<"\nnhap ma tran thu 2:";
c.nhap();
cout<<"\nma tran vua nhap:";
c.hien();
s=b+c;
t=b-c;
u=b*c;
v=b/c;
cout<<"\nma tran tong:";
s.hien();
cout<<"\nma tran hieu:";
t.hien();
cout<<"\nma tran tich:";
u.hien();
cout<<"\nma tran thuong:";
v.hien();
return 0;
}