Advertisement
Guest User

Untitled

a guest
Jan 17th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public class Main {
  2.  
  3.  
  4.     public static void main(String[] args) {
  5.         // write your code here
  6.  
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int matrix[][] = new int[3][3];
  10.         int matrix2[][] = new int[3][3];
  11.         int result[][] = new int[3][3];
  12.  
  13.         for (int i = 0; i < 3; i++) {
  14.             for (int j = 0; j < 3; j++) {
  15.                 matrix[i][j] = scan.nextInt();
  16.             }
  17.         }
  18.         for (int i = 0; i < 3; i++) {
  19.             for (int j = 0; j < 3; j++) {
  20.                 matrix2[i][j] = scan.nextInt();
  21.             }
  22.         }
  23.  
  24.         for (int i = 0; i < 3; i++) {
  25.             for (int j = 0; j < 3; j++) {
  26.                 result[i][j] = 0;
  27.                 for (int k = 0; k < 3; k++) {
  28.                     result[i][j] += matrix[i][k] * matrix2[k][j];
  29.                 }
  30.                 System.out.print(result[i][j] + " ");
  31.             }
  32.             System.out.println();
  33.         }
  34.  
  35.  
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement