#include<stdio.h>
#define n 3
int main (void)
{
int i,j,k;
double a[n][n] = {1,5,8,7,4,5,6,9,4};
double b[n][n] = {0,6,9,8,7,4,5,4,5};
double c[n][n] = {0};
/*求矩阵相乘*/
for(i = 0;i<n;i++)
{
for(j = 0;j<n;j++)
{
for(k=0;k<n;k++)
{
c[i][j] += a[i][k]*b[k][j];
}
}
}
printf("矩阵a和b的乘积是:\n");
for(i = 0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%lf\t",c[i][j]);
}
printf("\n");
}
return 0;
}
C语言求矩阵相乘
于 2022-03-26 17:20:26 首次发布