#include <iostream>
using namespace std;
int main()
{int A_row,A_column,B_row,B_column;
int A[10][10],B[10][10];
int C[10][10]={0};
int i,j,k;
cout<<"please input A_row,A_column,B_row,B_column:";
cin>>A_row>>A_column>>B_row>>B_column;
if(A_column==B_row)
{cout<<"input matrix A:"<<endl;
for(i=0; i<A_row;i++)
{for(j=0;j<A_column;j++)
cin>>A[i][j];
}
cout<<endl;
cout<<"iuput matrix B:"<<endl;
for(i=0;i<B_row;i++)
{for(j=0;j<B_column;j++)
cin>>B[i][j];
}
cout<<endl;
cout<<"matrix C:"<<endl;
for(i=0;i<A_row;i++)
{for(j=0;j<B_column;j++)
{for(k=0;
k<A_column;k++)
C[i][j]+=A[i][k]*B[k][j];
cout<<C[i][j]<<" ";}
cout<<endl;
}
}
else cout<<"error!";
return 0;
}
这就可以了。虽然与我理想中的还有差距。