1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include<iostream> using namespace std; int main() { int m, n, t; int a[100][100], b[100][100], c[100][100]; cin >> m >> n; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; cin >> n >> t; for (int i = 0; i < n; i++) for (int j = 0; j < t; j++) cin >> b[i][j]; for (int i = 0; i < m; i++) { for (int j = 0; j < t; j++) { c[i][j] = 0; for (int k = 0; k < n; k++) c[i][j] = c[i][j] + a[i][k] * b[k][j]; } } for (int i = 0; i < m; i++) { for (int j = 0; j < t; j++) { if (j > 0) cout << " "; cout << c[i][j]; } cout << endl; } return 0; } |
2018年10月8日 星期一
itsa [C_AR62-中]矩陣相乘
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言