fork(4) download
  1. #include <iostream>
  2.  
  3. void Multiply(float N[4][4], float M[4][4], float Result[4][4])
  4. {
  5. for (int I = 0; I < 4; ++I)
  6. {
  7. for (int J = 0; J < 4; ++J)
  8. {
  9. double SumElements = 0.0;
  10. for (int K = 0; K < 4; ++K)
  11. {
  12. SumElements += M[I][K] * N[K][J];
  13. }
  14. Result[I][J] = SumElements;
  15. }
  16. }
  17. }
  18.  
  19. void Print(float mat[4][4])
  20. {
  21. for (int i = 0; i < 4; ++i)
  22. {
  23. for (int j = 0; j < 4; ++j)
  24. {
  25. std::cout<<mat[i][j]<<" ";
  26. }
  27. std::cout<<"\n";
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. float N[4][4] =
  34. {
  35. {1, 2, 3, 4},
  36. {5, 6, 7, 8},
  37. {9, 10, 11, 12},
  38. {13, 14, 15, 16}
  39. };
  40.  
  41. float M[4][4] =
  42. {
  43. {1, 2, 3, 4},
  44. {5, 6, 7, 8},
  45. {9, 10, 11, 12},
  46. {13, 14, 15, 16}
  47. };
  48.  
  49. float Result[4][4];
  50.  
  51. Multiply(N, M, Result);
  52. Print(Result);
  53. }
  54.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
90 100 110 120 
202 228 254 280 
314 356 398 440 
426 484 542 600