#include <iostream> #include <windows.h> using namespace std; int main(void) { double value = 12.3456789; // cout默认输出6位有效数字 cout << value << endl; // 修改cout的输出精度,设置成输出4位有效数字 cout.precision(4); cout << value << endl; // 设置输出小数点后面的5位有效数字 cout.precision(5); cout.flags(cout.fixed); //定点法,设置小数点后面输出的位数 cout << value << endl; // 取消定点法 cout.unsetf(cout.fixed); cout << value << endl; system("pause"); return 0; }
输出结果
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/602505.html