Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- // write your code here
- Scanner scan = new Scanner(System.in);
- int matrix[][] = new int[3][3];
- int matrix2[][] = new int[3][3];
- int result[][] = new int[3][3];
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- matrix[i][j] = scan.nextInt();
- }
- }
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- matrix2[i][j] = scan.nextInt();
- }
- }
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- result[i][j] = 0;
- for (int k = 0; k < 3; k++) {
- result[i][j] += matrix[i][k] * matrix2[k][j];
- }
- System.out.print(result[i][j] + " ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement