如何在C++中格式化浮点数以输出四舍五入的小数位?我有没有运气setw,并setprecision为我的编译器只是告诉我,他们是not defined.
setw
setprecision
not defined
cout << "Total : " << setw(2) << total << endl;
总产出: Total : 12.3961
Total : 12.3961
我希望它是:12.40或者12.39如果要完成这项工作太多了.
12.40
12.39
c++ floating-point cout
c++ ×1
cout ×1
floating-point ×1