解题思路:
注意事项:
参考代码:
package arrLast; //题目 2884: 矩阵乘法 import java.util.Scanner; public class t_2884 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt(); int [][]a=new int [n][m]; int [][]b=new int [m][k]; int [][]c=new int [n][k]; for(int i=0;i<a.length;i++) { for(int j=0;j<a[i].length;j++) { a[i][j]=sc.nextInt(); } } for(int i=0;i<b.length;i++) { for(int j=0;j<b[i].length;j++) { b[i][j]=sc.nextInt(); } } for(int i=0;i<c.length;i++) { for(int j=0;j<c[i].length;j++) { for(int x=0;x<m;x++) c[i][j]+=a[i][x]*b[x][j]; } } for(int i=0;i<c.length;i++) { for(int j=0;j<c[i].length;j++) { System.out.print(c[i][j]+" "); } System.out.println(); } } }
0.0分
0 人评分
【出圈】 (C语言代码)浏览:558 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:572 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:472 |
蛇行矩阵 (C语言代码)浏览:536 |
回文数字 (C语言代码)浏览:2510 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:679 |
星期判断机 (C语言代码)浏览:859 |
简单的a+b (C语言代码)浏览:581 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:588 |
C二级辅导-进制转换 (C语言代码)浏览:660 |