Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created July 16, 2019 02:27
Show Gist options
  • Save surinoel/792baa6eff82f097f8c58215baa8b133 to your computer and use it in GitHub Desktop.
Save surinoel/792baa6eff82f097f8c58215baa8b133 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int a[100][100];
int b[100][100];
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
int u, v;
cin >> u >> v;
for (int i = 0; i < u; i++) {
for (int j = 0; j < v; j++) {
cin >> b[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < v; j++) {
int sum = 0;
for (int k = 0; k < u; k++) {
sum += a[i][k] * b[k][j];
}
cout << sum << ' ';
}
cout << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment