登录 | 首页 -> 华新鲜事 -> 求学狮城 | 切换到:传统版 / sForum | 树形列表
,急,关于c++
<<始页  [1]  末页>> 

,急,关于c++这一句有什么问题?
cout<<"\t\t\t\t"<<setiosflag(sios::left)<<setw(17)<<"Tax"<<setprecision(2)<<tax<<endl<<endl;
[D (3-21 1:24, Long long ago)] [ 传统版 | sForum ][登录后回复]1楼

打错了,请看这cout<<"\t\t\t\t"<<setiosflags(ios::left)<<setw(17)<<"Tax"<<setprecision(2)<<tax<<endl<<endl;
[D (3-21 1:27, Long long ago)] [ 传统版 | sForum ][登录后回复]2楼

(引用 D:打错了,请看这cout...):) :) :)
What is your problem?

Do you want the output to be like this:(suppose tax=0.053)

--------------------------------Tax--------------0.05

?

//Before Tax 32 blanks and after Tax 14 blanks.





I think you might not be able to get 0.05, right?

This is because setprecision() should be used together

with "showpoint" or "fixed".

You can try this:

cout << "\t\t\t\t" << setiosflags(ios:left) << setw(17)
<< "Tax" << setiosflags(ios:fixed) << setprecision(2)
<< tax << endl << endl;

[魅力十足 (3-21 5:48, Long long ago)] [ 传统版 | sForum ][登录后回复]3楼


<<始页  [1]  末页>> 
登录 | 首页 -> 华新鲜事 -> 求学狮城 | [刷新本页] | 切换到:传统版 / sForum