setw(6)就是指定宽度为6,fixed<<setprecision(2)就是指定小数位精度为2位
double x = 6.218;
cout <<setw(6) <<fixed << setprecision(2) << x << endl; //输出结果为: 6.21
setw(6)就是指定宽度为6,fixed<<setprecision(2)就是指定小数位精度为2位
double x = 6.218;
cout <<setw(6) <<fixed << setprecision(2) << x << endl; //输出结果为: 6.21