printf 和cout
usrbin吧
全部回复
仅看楼主
level 8
莫须晴
楼主
对于双精度数a ,
我用cout 和printf("%f")输出的结果不一样...
到底如何用printf输出double类型的数 = =
2011年10月14日 07点10分
1
level 11
usrbin
double => printf("%lf",&x)
2011年10月14日 08点10分
2
level 6
好吃的慕斯
不是应该是这样的吗?
double => printf("%lf",x);
2011年10月14日 08点10分
3
level 11
usrbin
原谅我的大脑短路吧..
2011年10月14日 08点10分
4
level 8
莫须晴
楼主
double a,b;
cin>>a>>b;
a/=b;
cout<<a<<endl;
printf("%lf",&a);
2011年10月14日 08点10分
5
level 8
莫须晴
楼主
50
3
16.6667
16.666657
2011年10月14日 08点10分
6
level 8
莫须晴
楼主
double a,b;
cin>>a>>b;
a/=b;
cout<<a<<endl;
printf("%lf",a);
2011年10月14日 08点10分
7
level 8
莫须晴
楼主
50
3
16.6667
16.666667
2011年10月14日 08点10分
8
level 8
莫须晴
楼主
还是不一样
2011年10月14日 08点10分
9
level 11
usrbin
you can refer to "cout << setiosflags(ios::fixed)" and "cout << setprecision(n)"
2011年10月14日 08点10分
10
level 7
不是镜镜💕
cout好像加些什么,反正我不会
2011年10月14日 08点10分
11
level 8
莫须晴
楼主
我明白了
2011年10月14日 09点10分
12
level 11
铁砣陈
感觉c++有点让人蛋疼…
2011年10月14日 09点10分
13
level 8
莫须晴
楼主
我萌学的是C++,可是做题时却用C....
2011年10月14日 09点10分
14
level 11
铁砣陈
听过,传说hust也是……
2011年10月14日 10点10分
15
level 11
闹事堂风
c++默认是保留6位有效数字。
2011年10月14日 13点10分
16
1