| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 33284 人关注过本帖
标题:double输出格式是%lf吗?
只看楼主 加入收藏
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
 问题点数:0 回复次数:17 
double输出格式是%lf吗?
double输出格式是%lf吗?
搜索更多相关主题的帖子: double 格式 输出 
2007-08-29 08:02
臥龍孔明
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2006-12-16
收藏
得分:0 

%f


[shadow=255,red,2]未出隆中-----已知三分[/shadow] [shadow=255,blue,2]运筹帷幄-----决胜千里[/shadow]
2007-08-29 11:28
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
得分:0 
float也是%f,这两种就没区别了~~

一分耕耘,一分收获。
2007-08-29 11:33
viky2003
Rank: 5Rank: 5
等 级:职业侠客
帖 子:375
专家分:383
注 册:2007-4-11
收藏
得分:0 
lf

要练习算法就来http:///!!有挑战哦!!
2007-08-29 16:17
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
得分:0 

到底应该是怎样呢?


一分耕耘,一分收获。
2007-08-29 16:20
coachard
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:1251
专家分:0
注 册:2007-8-12
收藏
得分:0 
lf,用f会丢失掉精度~~~~~

偶学编程,也许本身就是一个错。。。
2007-08-29 16:21
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
%f or %lf 都可以



by 雨中飞燕 QQ:78803110 QQ讨论群:5305909

请大家不要用TC来学习C语言
C/C++算法习题(OnlineJudge):[url]http://yzfy.org/[/url]
2007-08-29 17:33
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
回复:(雨中飞燕)%f or %lf 都可以[img]http://bbs....


No, simply f, Neither lf nor Lf:

For printf():

l: The argument is interpreted as a long int or unsigned long int for integer specifiers (i, d, o, u, x and X), and as a wide character or wide character string for specifiers c and s.
L: The argument is interpreted as a long double (only applies to floating point specifiers: e, E, f, g and G).


For scanf():

l : long int (for d, i and n), or unsigned long int (for o, u and x), or double (for e, f and g)
L : long double (for e, f and g)


I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-08-29 18:01
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
得分:0 
版主,我看得不很明白,但是在下面这个程序中:
#include<stdio.h>
main()
{
double t;
scanf("%f",&t);
printf("%f",t);
}
//输入1,结果 -92559604281615349000000000000000000000000000000000000000000000.000000
改为:scanf("%lf",&t);就OK了.为什么?



一分耕耘,一分收获。
2007-08-29 18:20
Maltase
Rank: 1
等 级:新手上路
帖 子:105
专家分:0
注 册:2007-8-7
收藏
得分:0 
因为你定义的是double类型的

读书....努力读书.....
2007-08-29 19:15
快速回复:double输出格式是%lf吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017322 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved