题目中公式j的范围写错了,误导人。应该是0<= j < z;

import java.util.*;
public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            while(sc.hasNextInt()) {
                int x = sc.nextInt();
                int y = sc.nextInt();
                int z = sc.nextInt();
                int[][] a = new int[x][y];
                for (int i =0; i < x; i++) {
                    for (int j =0; j< y; j++) {
                        a[i][j] = sc.nextInt();
                    }
                }
                int[][] b = new int[y][z];
                for (int i =0; i < y; i++) {
                    for (int j =0; j< z; j++) {
                        b[i][j] = sc.nextInt();
                    }
                }
                int[][] c = new int[x][z];
                for (int i =0; i < x; i++) {
                    for (int j =0; j< z; j++) {
                        for (int k =0; k < y; k++) {
                                 c[i][j] += a[i][k] * b[k][j];
                        }
                    }
                }
                for (int i =0; i < x; i++) {
                    for (int j =0; j< z; j++) {
                        System.out.print(c[i][j]);
                        if (j != z-1) {
                            System.out.print(" ");
                        }
                    }
                    System.out.println("");
                }
            }
        }
}