0
我有一個浮點數,我想在小數點後打印一位數字。我如何使用cout
來做到這一點?我已經嘗試了下面的代碼,但它給出了錯誤的顯示。使用cout打印一個(浮點數)小數
#include <iostream>
using namespace std;
int main()
{
float time = 2.2;
cout.precision(1);
cout << time << endl;
return 0;
}
似乎需要一個鏈接到[無法](http://www.aristeia.com/Papers/C++ReportColumns/novdec95.pdf)(PDF格式)由斯科特邁耶斯的鏈接:) – sehe
那麼,如果我要鏈接一篇文章,我當然會鏈接[this](http://kuhllib.com/2012/01/14/stop-excessive-use-of-stdendl/)!我真的不知道斯科特的文章... –
而我真的不知道你的:)謝謝你的鏈接 – sehe