0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:25:25 +00:00

B2105 矩阵乘法

https://www.luogu.com.cn/record/172635940
This commit is contained in:
Baoshuo Ren 2024-08-14 16:32:37 +08:00
parent 6e204c1db6
commit 39680422a4
Failed to extract signature

47
Luogu/B2105/B2105.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n, m, k;
int a[N][N], b[N][N], c[N][N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= k; j++) {
cin >> b[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
for (int l = 1; l <= m; l++) {
c[i][j] += a[i][l] * b[l][j];
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cout << c[i][j] << ' ';
}
cout << endl;
}
return 0;
}