-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionMult.java
More file actions
46 lines (41 loc) · 1.03 KB
/
FunctionMult.java
File metadata and controls
46 lines (41 loc) · 1.03 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
40
41
42
43
44
45
46
public class FunctionMult {
public static void main(String[] args) {
int[][] a = {
{-9,1,0,2,5},
{4,1,1,3,4},
{-2,2,-1,-1,7},
{2,-3,5,6,-4},
{1, -3, 8, 9, 4}
};
int[][] b = {
{1 , 2 , 3 , 4 },
{3 , -2, 7, 4 },
{2 , 1 , 1 , 5},
{-7, 3, -1, 4},
{9 , 5, -3, 6}
};
int[][] c = new int[a.length][b[0].length];
umn(a, b, c);
for (int i = 0; i < c.length; i++) {
for (int j = 0; j < c[0].length; j++) {
System.out.println(c[i][j]);
}
System.out.println();
}
}
public static int umn (int a[][] , int b[][], int c[][] ) {
int m = a.length;
int n = b[0].length;
int o = b.length;
if (a[0].length == b.length) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < o; k++) {
c[i][j] += a[i][k] * b[k][j];
}
}
}
}
return m;
}
}