Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. package pkgandrei;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class TestEA15 {
  6.  
  7. public static int[][] getMatrixProduct(int[][] matrix1, int[][] matrix2) {
  8. int[][] prodMatrix = new int[matrix1.length][matrix1.length];
  9. for (int i = 0; i < matrix1.length; i++) {
  10. for (int j = 0; j < matrix1.length; j++) {
  11. for (int k = 0; k < matrix2.length; k++) {
  12. prodMatrix[i][j] += matrix1[i][k] * matrix2[k][j];
  13. }
  14. }
  15. }
  16.  
  17. return prodMatrix;
  18.  
  19. }
  20.  
  21. public static void main(String[] args) {
  22. System.out.println(Arrays.deepToString(
  23. (getMatrixProduct(new int[][] { { 4, 2 }, { 0, 1 } }, new int[][] { { 0, 2 }, { 2, 1 } }))));
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement