C++输入输出格式--保留n位小数
来源:互联网 发布:hmmlearn python 教程 编辑:程序博客网 时间:2024/06/05 15:52
打印:
#include<iostream>#include<iomanip>using namespace std;double p=0.123456789;int main(){ cout<<setiosflags(ios::fixed)<<setprecision(6)<<p<<endl;///0.123457 return 0;}
http://images2015.cnblogs.com/blog/733943/201604/733943-20160422194116085-617979812.jpg
浮点数四舍五入取数:
#include<iostream>#include<iomanip>using namespace std;double a=1.1,b=1.6,c=2.4;int main(){ cout<<(int)(a+0.5)<<endl;// 1 cout<<(int)(b+0.5)<<endl;// 2 cout<<(int)(c+0.5)<<endl;// 2 cout<<setiosflags(ios::fixed)<<setprecision(0)<<c<<endl;// 2 return 0;}
阅读全文
0 0
- C++输入输出格式--保留n位小数
- C语言double保留N位小数
- 保留小数后N位
- 四舍五入,保留N位小数
- C#小数保留N位
- java:保留n位小数
- double保留n位小数
- float-保留N位小数
- java保留n位小数
- js 保留n位小数
- 【js】小数保留n位小数
- java 保留小数后N位小数
- [Asp.Net]decimal 保留n位小数
- java四舍五入、保留n位小数
- Java除法保留N位小数
- java中的保留n位小数
- C#保留N位小数的方法
- php , jquery 保留n位小数
- iconv命令
- 7.8noip测试
- 实现List和Map数据的转换
- 我的小小学习笔记(5)之C++-----缺省函数
- Java8的HashMap详解(存储结构,功能实现,扩容优化,线程安全,遍历方法)
- C++输入输出格式--保留n位小数
- Shiro 采用注解方式无法进入自定义Realm类的授权方法 解决方案
- nginx 优化
- Macaca Macaca 实现 IOS Monkey 测试 (支持 macaca2.x 版本)
- volatile关键字
- 51Nod
- cout.put()
- c/c++实现堆排序
- React-Navigation与Redux整合详解