C++学习 cout的格式化输出

cout的格式化输出

1.常用:

  ①double 输出到小数点后n位:(保留精度 n位)

1 #include <iostream>
2 #include <iomanip>
3 using namespace std;
4 int main()
5 {
6     cout.setf(ios::fixed);
7     cout<<fixed<<setprecision(6)<<0.222<<endl;//输出:0.222000
8 }

2017-03-27 00:32:17 (常用 ①)

原文地址:https://www.cnblogs.com/Twobox/p/6624903.html