C++ 输出流格式控制
(1)fixed:设置为定点输出方式。
ofstream f;f.open(filename.c_str());f << fixed;
(2)setprecision(k):设置输出精度。
f << setprecision(6) << a << " " << setprecision(9) << b << " " << c << " " << endl;
- a 使用 6 位小数。
- b, c使用 9 位小数。
(1)fixed:设置为定点输出方式。
ofstream f;f.open(filename.c_str());f << fixed;
(2)setprecision(k):设置输出精度。
f << setprecision(6) << a << " " << setprecision(9) << b << " " << c << " " << endl;