-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmatrixMultiplay.java
More file actions
39 lines (35 loc) · 1.21 KB
/
matrixMultiplay.java
File metadata and controls
39 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class matrixMultiplay {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int num[][] = new int[3][3];
int num1[][] = new int[3][3];
int num2[][] = new int[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
num1[i][j] = Integer.parseInt(br.readLine());
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
num2[i][j] = Integer.parseInt(br.readLine());
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
num[i][j] = 0;
for (int z = 0; z < 3; z++) {
num[i][j] = num[i][j] + (num1[i][z]*num2[z][j]);
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(" "+num[i][j]);
}
System.out.println();
}
}
}