Created
December 15, 2017 11:49
-
-
Save oskimura/b980de03eb80b8b29b8c40ade41b7914 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
#include <functional> | |
#include <numeric> | |
int main() | |
{ | |
int n,m,l; | |
std::cin >> n >> m >> l; | |
int **matrix1 = new int*[n]; | |
for (int i=0;i<n;i++) { | |
matrix1[i] = new int[m]; | |
} | |
for (int i=0; i<n; i++) { | |
for (int j=0; j<m; j++) { | |
int num; | |
std::cin >> num; | |
matrix1[i][j] = num; | |
} | |
} | |
int **matrix2 = new int*[m]; | |
for (int i=0;i<m;i++) { | |
matrix2[i] = new int[l]; | |
} | |
for (int i=0;i<m;i++) { | |
for (int j=0;j<l;j++) { | |
int num; | |
std::cin >> num; | |
matrix2[i][j] = num; | |
} | |
} | |
long ** result = new long*[n]; | |
for (int i=0;i<n;i++) { | |
result[i] = new long[l]; | |
} | |
for (int i=0;i<n;i++) { | |
for (int j=0;j<l;j++) { | |
result[i][j] = 0; | |
} | |
} | |
for (int i=0;i<n;i++) { | |
for (int j=0;j<m;j++) { | |
for (int k=0;k<l;k++) { | |
result[i][k] += matrix1[i][j] * matrix2[j][k]; | |
} | |
} | |
} | |
for (int i=0; i<n;i++) { | |
for (int j=0;j<l;j++) { | |
std::cout << result[i][j]; | |
if (j!=l-1) { | |
std::cout << " "; | |
} | |
} | |
std::cout << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment