→ sb0917:對喔...我都問忘了改XDD...精華區那篇不能跑請D掉 12/08 01:44
#include <iostream>
using namespace std;
int main()
{
int M=11,N=11,L=11;
int A[11][11],B[11][11],C[11][11]={0};
cout<<"輸入M,L,N"<<endl;
cin>>M>>L>>N;
cout<<"輸入MxL個數字(矩陣A)"<<endl;
for(int i=0;i<M;i++)
for(int j=0;j<L;j++)
cin>>A[i][j];
cout<<"輸入LxN個數字(矩陣B)"<<endl;
for(int i=0;i<L;i++)
for(int j=0;j<N;j++)
cin>>B[i][j];
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
for(int k=0;k<L;k++)
C[i][j]+=A[i][k]*B[k][j];
cout<<"矩陣C(C=AxB)"<<endl;
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
cout<<C[i][j]<<"\t";
cout<<endl;
}
system("pause");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.241.88
※ 編輯: vincent79715 來自: 140.112.241.88 (12/08 01:28)
※ 編輯: vincent79715 來自: 140.112.241.88 (12/08 01:29)