Advertisement
ThePeeters

problema4 java

Feb 23rd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. import acm.program.ConsoleProgram;
  3.  
  4. /*
  5. * To change this license header, choose License Headers in Project Properties.
  6. * To change this template file, choose Tools | Templates
  7. * and open the template in the editor.
  8. */
  9.  
  10. /**
  11. *
  12. * @author prb7
  13. */
  14. public class Problema4 extends ConsoleProgram {
  15. public void run(){
  16. }
  17. public int[][] matrixMultiplication (int[][]left,
  18. int[][]right){
  19. int[][] multiplication = new int [left.length][right[0].length];
  20. for(int i=0; i<multiplication.length; i++){
  21. for(int j=0; i< multiplication[0].length;j++){
  22. /*int res = 0;
  23. for(int k=0;k<left[0].length;k++){
  24. res+=left[i][k]*right[k][j];
  25. }*/
  26. //multiplication[i][j]=res;
  27. multiplication[i][j]=calcule(i,j,left,right);
  28.  
  29. }
  30. }
  31. return multiplication;
  32. }
  33. public int calcule(int i, int j,int[][]left,
  34. int[][]right){
  35. int res = 0;
  36. for(int k=0;k<left[0].length;k++){
  37. res+=left[i][k]*right[k][j];
  38. }
  39. return res;
  40. }
  41. }//end public class
  42.  
  43.  
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement