Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Tabela
- {
- int tab[3][3];
- public:
- void vpis();
- void izpis();
- Tabela operator+(Tabela);
- Tabela operator-(Tabela);
- Tabela operator*(Tabela);
- };
- void Tabela::vpis(){
- for(int i=0;i<3;i++)
- for(int j=0;j<3;j++)
- cin>>tab[i][j];
- }
- void Tabela::izpis(){
- for(int i=0;i<3;i++)
- {for(int j=0;j<3;j++)
- cout<<tab[i][j]<<" ";
- cout<<endl;}
- }
- Tabela Tabela::operator +(Tabela z)
- {
- Tabela x;
- for(int i=0;i<3;i++)
- for(int j=0;j<3;j++)
- {
- x.tab[i][j]=tab[i][j]+z.tab[i][j];
- }
- return x;
- }
- Tabela Tabela::operator -(Tabela z){
- Tabela x;
- for(int i=0;i<3;i++)
- for(int j=0;j<3;j++)
- {
- x.tab[i][j]=tab[i][j]-z.tab[i][j];
- }
- return x;
- }
- Tabela Tabela::operator *(Tabela z){
- Tabela x;
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<3;j++)
- {
- x.tab[i][j]=0;
- for(int k=0;k<3;k++)
- {
- x.tab[i][j]+=(tab[i][k]*z.tab[k][j]);
- }
- }
- }
- return x;
- }
- int main()
- {
- Tabela a,b,O;
- a.vpis();
- b.vpis();
- O=a*b;
- O.izpis();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement