奇怪的矩阵相乘程序结果,求修改
主程序里边调用了一个矩阵相乘的程序,两个单位矩阵相乘,结果应该得到一个单位矩阵,但是计算的结果很奇怪,求各位高手解答#include <stdio.h>
void matproduct(float a2[3][3],float b2[3][3],float c2[3][3]);
int main()
{
int i;
float s[3][3];
float a[3][3]={{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
float b[3][3]={{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
matproduct(a,b,s);
for(i=0;i<3;i++)
printf("%d %d %d \n",s[i][1],s[i][2],s[i][3]);
return 0;
}
void matproduct(float a2[3][3],float b2[3][3],float c2[3][3]) //对矩阵进行乘法运算,结果存储到c矩阵中
{int i1,j1;
for (i1=0;i1<3;i1++)
for (j1=0;j1<3;j1++)
{c2[i1][j1]=a2[i1][0]*b2[0][j1]+a2[i1][1]*b2[1][j1]+a2[i1][2]*b2[2][j1];}
}