#include<iostream> #include<cstdio> using namespace std; const int MAXN=3; struct Matrix{ int row,col; int matrix[MAXN][MAXN]; Matrix(int r,int c):row(r),col(c){} }; Matrix Multiply(Matrix x,Matrix y){ Matrix ans=Matrix(x.row,y.col); for(int i=0;i<ans.row;++i){ for(int j=0;j<ans.col;++j){ ans.matrix[i][j]=0; for(int k=0;k<x.col;++k){ ans.matrix[i][j]+=x.matrix[i][k]*y.matrix[k][j]; } } } return ans; } void CinMatrix(Matrix &x){ for(int i=0;i<x.row;++i){ for(int j=0;j<x.col;++j){ scanf("%d",&x.matrix[i][j]); } } } void CoutMatrix(Matrix x){ for(int i=0;i<x.row;++i){ for(int j=0;j<x.col;++j){ printf("%d ",x.matrix[i][j]); } printf("\n"); } } int main(){ Matrix a=Matrix(2,3); Matrix b=Matrix(3,2); CinMatrix(a); CinMatrix(b); CoutMatrix(Multiply(a, b)); return 0; }