求助??两个矩阵乘积??
#include "stdio.h"#define N 3
#define K 2
#define M 4
void main()
{int i,j,m,n,k,l;
int a[N][K],b[K][M],c[N][M];
printf("please input number for a[i][j]\n");
for (i=0;i<N;i++)
for (j=0;j<K;j++)
scanf("%d",&a[i][j]);
printf("please input number for b[i][j]\n");
for (i=0;i<K;i++)
for (j=0;j<M;j++)
scanf("%d",&b[i][j]);
for (i=0;i<N;i++)
for (j=0;j<M;j++)
{c[i][j]=0;
for (l=0;l<K;l++)
c[i][j]+=a[i][l]*b[l][j];}
printf("output a and b\n");
for (i=0;i<N;i++)
for (j=0;j<M;j++)
{if (i%M==0)
printf("\n");
printf("%4d",c[i][j]);}}
当输入A[i][j]:3 7 5 9 2 6
B[i][j]:1 2 7 4 5 3 9 8
C[i][j]:38 27 84 68 50 37 116 92 32 22 68 56
请说一下A和B是怎样矩阵相乘的?不明白C数组的元素是怎样得出来的?
[[it] 本帖最后由 MARK357640995 于 2008-10-28 22:23 编辑 [/it]]