Ja5oN 发表于 2007-1-1 16:23

为什么我用f格式符不能输入双精度浮点数据?


#include <stdio.h>
void main()
{
double a=5;
scanf ("%f",&a);
printf("%f",a);
}

为什么我运行上面程序时无论我从键盘输入什么数据最终都显示5.00001???

iptton 发表于 2007-1-1 16:32

printf( "%lf",a )
scanf(" %lf",&a);

double 是 lf(long float)

[ 本帖最后由 iptton 于 2007-1-2 16:02 编辑 ]

MJOfPowerwind 发表于 2007-1-1 16:33

先参考下这个帖
https://www.gdutbbs.com/viewthread.php?tid=74147

Ja5oN 发表于 2007-1-1 16:44

谢谢!
页: [1]
查看完整版本: 为什么我用f格式符不能输入双精度浮点数据?