import java.util.*;
/**
* 矩阵乘法
* @author Green.Gee
* @date 2022/11/21 15:55
* @email green.gee.lu@gmail.com
*/
public class MatrixMinus {
/**
* 矩阵乘法条件
* 如果A是个x行y列的矩阵,
* B是个y行z列的矩阵,
* 把A和B相乘,
* 其结果将是另一个x行z列的矩阵C。
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
int x = in.nextInt();// 第一个矩阵行数
int y = in.nextInt();// 第一个矩阵列数和第二个矩阵行数
int z = in.nextInt();// 第二个矩阵列数
int[][] a = new int[x][y];
int[][] b = new int[y][z];
for(int i = 0; i < x; i++){
for(int j = 0; j < y; j++){
a[i][j] = in.nextInt();
}
}
for(int i = 0; i < y; i++){
for(int j = 0; j < z; j++){
b[i][j] = in.nextInt();
}
}
int[][] c = new int[x][z];
int count = 0;
for(int i = 0; i < z; i++){
for(int k = 0; k < x; k++){
int temp = 0;
for(int j = 0; j < y; j++){
int a1 = a[k][j];
int b1 = b[j][i];
temp += a1 * b1;
count++;
}
c[k][i] = temp;
}
}
System.err.println("count->"+count);
for(int i = 0; i < x; i++){
for(int k = 0; k < z - 1; k++){
System.out.print(c[i][k]+" ");
}
System.out.print(c[i][z - 1]+"\n");
// 正则打印
// System.out.println(Arrays.toString(c[i]).replaceAll("\\[","").replaceAll("\\]","").replaceAll("\\,",""));
}
}
}
}
03-19