cout<<setprecision(3)<<3.1415926;
输出结果:3.14
cout<<setprecision(3)<<fixed<<3.1415926;
输出结果:3.142;
加fixed能实现小数点后n位(四舍五入)
cout<<setw(4)<<3.14;
输出结果:3.14(‘ . ’也算一位)
cout<<setw(4)<<3;
输出结果: 3;(默认前面补‘ ’,共四位)
cout<<setw(4)<<setfill('0')<<3;
输出结果:0003;