Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
27948 纪哲弘 矩阵乘法 C++ Accepted 7 MS 852 KB 559 2022-06-12 17:35:01

Tests(10/10):


Code:

#include<iostream> #include<cmath> using namespace std; int main(){ int temp=0,a[101][101],b[101][101],c[101][101]={0},n,m,k; cin>>n>>m>>k; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>a[i][j]; } } for(int i=0;i<m;i++){ for(int j=0;j<k;j++){ cin>>b[i][j]; } } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ temp=0; for(int z=0;z<m;z++){ temp+=a[i][z]*b[z][j]; } c[i][j]=temp; } } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cout<<c[i][j]<<' '; } cout<<endl; } return 0; }