我发布了要求用户输入矩阵的代码部分,但显示时它只显示0.000000作为其元素。请保证找出我不适当的事情。c程序的输出为零,但它需要来自用户的输入
#include<stdio.h>
main(){
int i,j,m,x,c,l;
double mat[100][100],temp[100],a[100][100],lt[100][100]={0.000},ut[100][100],maximum,per[100][100];
printf("Enter the size of square matrix: ");
scanf("%d", &m);
//enter the matrix
for(i=0;i<m;i++)
{
printf("enter the row %d: \n", i+1);
for(j=0;j<m;j++){
scanf("%f",&mat[i][j]);
a[i][j]=mat[i][j];
}
}
//show matrix
printf("matrix =\n");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
printf("%f\t", mat[i][j]);
}
printf("\n");
}
打开编译器警告,您将了解到您需要'scanf'中的'%lf'来扫描'double'。 (但'_finting_''f''%f'虽然是好的。) – 2015-01-26 18:28:05
感谢它解决了这个问题。 – 2015-01-28 03:53:01