fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main ()
  4. {
  5. int a[3][3]={ {-1,2,-3},
  6. {0,2,7},
  7. {2,-2,5}
  8. };
  9.  
  10. int b[3][3]={ {-1,9,-6},
  11. {0,6,8},
  12. {5-8,4}
  13. };
  14.  
  15. int c[3][3]={0};
  16. for(int i=0;i<3;i++){
  17. for(int j=0;j<3;j++){
  18. for(int k=0;k<3;k++){
  19. c[i][j]+=a[i][k]*b[k][j];
  20. }
  21. }
  22. }
  23. cout<<"Matrix A: "<<endl;
  24. for(int i=0;i<3;i++){
  25. for(int j=0;j<3;j++){
  26. cout<<a[i][j]<<" ";
  27. }
  28. cout<<endl;
  29. }
  30. cout<<"Matrix B: "<<endl;
  31. for(int i=0;i<3;i++){
  32. for(int j=0;j<3;j++){
  33. cout<<b[i][j]<<" ";
  34. }
  35. cout<<endl;
  36. }
  37. cout<<"Matrix c= "<<endl;
  38. for(int i=0;i<3;i++){
  39. for(int j=0;j<3;j++){
  40. cout<<c[i][j]<<" ";
  41. }
  42. cout<<endl;
  43. }
  44. }
  45.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
Matrix A: 
-1 2 -3 
0 2 7 
2 -2 5 
Matrix B: 
-1 9 -6 
0 6 8 
-3 4 0 
Matrix c= 
10 -9 22 
-21 40 16 
-17 26 -28