#include<iostream> using namespace std; void nhapmt(int a[50][50],int hang,int cot) { int i,j; for(i=0;i<hang;i++) for(j=0;j<cot;j++) { cout<<"a["<<i<<"]["<<j<<"]="; cin>>a[j]; } } void xuatmt(int a[50][50],int hang,int cot) { int i,j; for(i=0;i<hang;i++) { for(j=0;j<cot;j++) cout<<a[j]<<" "; cout<<"\n"; } } void main() { int a[50][50]; int b[50][50]; int c[50][50]; int hang1,hang2,cot1,cot2; cout<<"ma tran a"<<endl; cout<<"nhap so hang: ";cin>>hang1; cout<<"nhap so cot: ";cin>>cot1; nhapmt(a,hang1,cot1); cout<<"ma tran b"<<endl; do { cout<<"nhap so hang: "; cin>>hang2; } while(cot1!=hang2); cout<<"nhap so cot: ";cin>>cot2; nhapmt(b,hang2,cot2); cout<<"ma tran a la: "<<endl; xuatmt(a,hang1,cot1); cout<<"ma tran b la: "<<endl; xuatmt(b,hang2,cot2); cout<<"ma tran tich la: "<<endl; int i,j,k; for(i=0;i<hang1;i++) for(j=0;j<cot2;j++) { c[j]=0; for(k=0;k<cot1;k++) c[j]+=a[k]*b[k][j]; } xuatmt(c,hang1,cot2); }