邯郸市建行网点:求实数矩阵相乘的程序

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 13:48:57
这是自己些的:
调试的时候出不来结果
#define S 5
#define T 5
#define H 1
#include<stdio.h>
main()
{float a[S][T],b[T][H],c[S][H];
int i,j,h;
printf("input a[S][T]:\n");
for(i=0;i<S;i++)
for(j=0;j<T;j++)
scanf("%f",&a[i][j]);
printf("input b[T][H]:\n");
for(i=0;i<T;i++)
for(j=0;j<H;j++)
scanf("%f",&b[i][j]);
for(i=0;i<S;i++)
for(j=0;j<H;j++)
for(h=0;h<T;h++)
{c[i][j]=0.0;
c[i][j]+=a[i][h]*b[h][j];
}
printf("put out the c[S][H]:\n");
for(i=0;i<S;i++)
for(j=0;j<H;j++)
{printf("%-5.3f",c[i][j]);
if(j==H-1) printf("\n");
}
}