如果要输出 x 位的变量 output .
x
output
cout << fixed << setprecision(x) << output << endl;
setprecision头文件是 <iomanip> .
<iomanip>