5、 矩阵乘法,定义可乘矩阵,计算相乘结果并用一层循环输出。
来源:百度知道 编辑:UC知道 时间:2024/06/19 00:05:11
c语言程序
#include<iostream>
using namespace std;
#define aRow 2
#define aColum 2
#define bRow 2
#define bColum 3
int main()
{
int a[aRow][aColum] = {1,2,3,4};
int b[bRow][bColum] = {1,2,3,4,5,6};
int c[aRow][bColum] ={0};
for(int i = 0 ; i < aRow; i++)
{
cout<<endl;
for(int j = 0;j < bColum; j++)
{
for(int k = 0; k < aRow; k++)
{
c[i][j] += a[i][k]*b[k][j];
}//end innest for
cout<<c[i][j]<<" ";
}//end inner for
}//end for
return 0;
}
就是这个,我调试过的,肯定没问题。
你给的分太少了^_^