输出结果保留几位小数

包含头文件

#include <iomanip>

输出代码

cout << fixed << showpoint << setprecision(1) << endl;
//设置浮点数以固定的小数位数显示,这里设置保留一位小数

C++11

posted @ 2020-04-17 21:39  程序虫  阅读(290)  评论(0编辑  收藏  举报