ITPub博客

首页 > 应用开发 > > 哪个大神帮忙解答一下!

哪个大神帮忙解答一下!

作者:dav2100 时间:2019-07-31 09:42:50 0 删除 编辑

float和double的用法区别 顺便帮我看看这两个代码。用double赋值后输出都是0.

#include <stdio.h>

main()

{

float x;

scanf("%f",&x);

x=(int)(x*100+0.5)/100.0;

printf("%0.3f",x);

}



#include <stdio.h>

main()

{

double x;

scanf("%f",&x);

x=(int)(x*100+0.5)/100.0;

printf("%0.3f",x);

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4479/viewspace-3145450/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-10-17

  • 博文量
    176
  • 访问量
    17570