请教一个问题,有scanf : floating point formats not linked错误提示
我写了一个矩阵乘法的程序,可在输入后矩阵的时候有错误提示如下:scanf : floating point formats not linked
Abnormal program termination
哪位高手帮忙解释下。
源程序:
#define M 10
#define N 10
#include <stdio.h>
struct matrix
{
int m,n;
float a[M][N];
};
struct matrix get_matrix() //这里输入矩阵,就是这里出错。
{
int i,j;
struct matrix matrix_t;
printf("m=");
scanf("%d",&matrix_t.m);
printf("n=");
scanf("%d",&matrix_t.n);
printf("The matrix:\n");
for(i=0;i<matrix_t.m;i++)
for(j=0;j<matrix_t.n;j++)
scanf("%f",&matrix_t.a[i][j]);//这里有错误提示。
return(matrix_t);
}
struct matrix matrix_m(struct matrix m1,struct matrix m2)
{
int i,j,k,l;
struct matrix matrix_t;
matrix_t.m=m1.m;
matrix_t.n=m2.n;
for(i=0;i<matrix_t.m;i++)
for(j=0;j<matrix_t.n;j++)
matrix_t.a[i][j]=0;
for(i=0;i<matrix_t.m;i++)
for(j=0;j<matrix_t.n;j++)
for(k=0;k<m1.n;k++)
matrix_t.a[i][j]=matrix_t.a[i][j]+m1.a[i][k]*m2.a[k][j];
return(matrix_t);
}
print_matrix(struct matrix matrix_t)
{
int i,j;
printf("m=%d , n=%d\n",matrix_t.m,matrix_t.n);
for(i=0;i<matrix_t.m;i++)
{
for(j=0;j<matrix_t.n;j++)
printf("%5.3f",matrix_t.a[i][j]);
printf("\n");
}
}
main()
{
int i,j;
struct matrix m1,m2,m3;
printf("Please input matrix 1\n");
m1=get_matrix();
printf("Please input matrix 2\n");
m2=get_matrix();
m3=matrix_m(m1,m2);
printf("The result is:\n");
print_matrix(m3);
}
[[it] 本帖最后由 zwinston 于 2008-11-2 14:24 编辑 [/it]]