Advertisement
Guest User

pastebin

a guest
Nov 26th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Tabela
  6. {
  7. int tab[3][3];
  8. public:
  9. void vpis();
  10. void izpis();
  11. Tabela operator+(Tabela);
  12. Tabela operator-(Tabela);
  13. Tabela operator*(Tabela);
  14.  
  15.  
  16. };
  17.  
  18. void Tabela::vpis(){
  19. for(int i=0;i<3;i++)
  20. for(int j=0;j<3;j++)
  21. cin>>tab[i][j];
  22. }
  23. void Tabela::izpis(){
  24. for(int i=0;i<3;i++)
  25. {for(int j=0;j<3;j++)
  26. cout<<tab[i][j]<<" ";
  27. cout<<endl;}
  28. }
  29.  
  30. Tabela Tabela::operator +(Tabela z)
  31. {
  32. Tabela x;
  33. for(int i=0;i<3;i++)
  34. for(int j=0;j<3;j++)
  35. {
  36. x.tab[i][j]=tab[i][j]+z.tab[i][j];
  37. }
  38. return x;
  39. }
  40.  
  41. Tabela Tabela::operator -(Tabela z){
  42. Tabela x;
  43. for(int i=0;i<3;i++)
  44. for(int j=0;j<3;j++)
  45. {
  46. x.tab[i][j]=tab[i][j]-z.tab[i][j];
  47. }
  48. return x;
  49. }
  50.  
  51. Tabela Tabela::operator *(Tabela z){
  52. Tabela x;
  53.  
  54. for(int i=0;i<3;i++)
  55. {
  56. for(int j=0;j<3;j++)
  57. {
  58. x.tab[i][j]=0;
  59. for(int k=0;k<3;k++)
  60. {
  61. x.tab[i][j]+=(tab[i][k]*z.tab[k][j]);
  62. }
  63. }
  64. }
  65. return x;
  66. }
  67.  
  68. int main()
  69. {
  70. Tabela a,b,O;
  71. a.vpis();
  72. b.vpis();
  73. O=a*b;
  74. O.izpis();
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement