矩阵乘法
来源:互联网 发布:java编程代码 编辑:程序博客网 时间:2024/04/29 21:50
import java.util.*;
import java.io.*;
public class 矩阵乘法 {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
int m = in.nextInt();
int s = in.nextInt();
int n = in.nextInt();
int[][] a = new int[m][s];
int[][] b = new int[s][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < s; j++) {
a[i][j] = in.nextInt();
}
}
for (int i = 0; i < s; i++) {
for (int j = 0; j < n; j++) {
b[i][j] = in.nextInt();
}
}
int[][] c = new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
c[i][j] = 0;
for (int k = 0; k < s; k++) {
c[i][j] += a[i][k] * b[k][j];
}
System.out.print(c[i][j] + " ");
}
System.out.println();
}
}
}
0 0
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- 矩阵乘法
- UVA 10767-Barcelona’s trams(DP+数学推导)
- Qt 防多开
- 如何解决ubuntu下找不到libgtk-x11-2.0.so.0
- LoadRunner的两个不一致(Controller和Analysis;Summary Peport和Graphs-Average Transaction Response )
- 腾讯2015实习生招聘---内推,提前批 腾讯2015实习生招聘TST计划,寻找下一代互联网精英
- 矩阵乘法
- swift UI专项训练11 ActionSheet
- nodejs qt笔记
- lnmp环境配置
- C++中的单例模式
- NSThread,NSInvocationOperation,NSBlockOperation,GCD解析
- MAC系统txt中文乱码解决办法~~~
- 模板的写法,写一个titleBar
- Tree