#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float a=3.146798;
cout<<a<<endl;
cout.setf(ios::fixed);
cout<<setprecision(6)<<a<<endl;//固定显示小数点后6位
return 0;
}
固定cout输出的小数点后位数
最新推荐文章于 2023-07-13 12:23:39 发布
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float a=3.146798;
cout<<a<<endl;
cout.setf(ios::fixed);
cout<<setprecision(6)<<a<<endl;//固定显示小数点后6位
return 0;
}