输出格式控制-操纵算子

/关于浮点数的格式/
#include
using namespace std;
int main()
{
float f=2.0/3.0,f1=0.000000001,f2=-9.9;
cout<cout.setf(ios::showpos); //强制在正数前加+号
cout<cout.unsetf(ios::showpos); //取消正数前加+号
cout.setf(ios::showpoint); //强制显示小数点后的无效0
cout<cout.unsetf(ios::showpoint); //取消显示小数点后的无效0
cout.setf(ios::scientific); //科学记数法
cout<cout.unsetf(ios::scientific); //取消科学记数法
cout.setf(ios::fixed); //按点输出显示
cout<cout.unsetf(ios::fixed); //取消按点输出显示
cout.precision(18); //精度为18,正常为6
cout<cout.precision(6); //精度恢复为6
return 0;
}
用操纵算子实现同样的功能