参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int k = scanner.nextInt(); int [][]a = new int[n][m]; int [][]b = new int[m][k]; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] = scanner.nextInt(); for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) b[i][j] = scanner.nextInt(); int [][]c = new int[n][k]; for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) for(int x = 0; x < m; x++) c[i][j] += a[i][x]*b[x][j]; for(int[] i: c) { for(int t: i) System.out.print(t + " "); System.out.println(); } } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:778 |
简单编码 (C++代码)(这里推荐用switch)浏览:999 |
C语言训练-求PI* (C语言代码)(正确结果竟然是谜一样的3.141591)浏览:1338 |
数组输出 (C语言代码)错误???浏览:602 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:632 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:900 |
剪刀石头布 (C语言代码)浏览:1792 |
WU-printf基础练习2 (C++代码)浏览:2061 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:564 |
IP判断 (C语言代码)浏览:819 |