c++ 输出保留n位小数点的数
2016-04-02 16:28
260 查看
需要导入的头文件是:
#include <iomanip> //在iomanip头文件中有对其进行格式操作的函数。
int main(){
...............
double num; //注意类型
cout<<setiosflags(ios::fixed); //可以设置以浮点数形式输出
cout.precision(n); //可以设置精度n
cout<<num<<endl;
return 0;
}
#include <iomanip> //在iomanip头文件中有对其进行格式操作的函数。
int main(){
...............
double num; //注意类型
cout<<setiosflags(ios::fixed); //可以设置以浮点数形式输出
cout.precision(n); //可以设置精度n
cout<<num<<endl;
return 0;
}
相关文章推荐
- C\C++ extern "C"解释
- 算法基础 杨辉三角形
- C++ 二维数组 创建
- 《C++ Primer》 第四版 第16章 模板与泛型编程
- C/C++读入写出空格和\0的区别
- 《C++ Primer》 第四版 第15章 面向对象编程
- 《C++ Primer》 第四版 第7章 函数
- C语言中qsort函数用法
- C语言的文件的操作(二)
- C语言的文件的操作(一)
- 【转】Ubuntu 上编译Android出现cannot find -lstdc++解决办法
- C\C++函数原型的意义
- Eclipse missing C/C++ build and general from project properties
- C语言 函数指针
- Notepad++变成C/C++的IDE
- C 【关键字&标识符】
- C++多态机制浅析
- sim900GPRS使用C语言打电话发短信
- C++指针理解《一》
- [leetcode ]221. Maximal Square c语言