u Calculate e
问题陈述:
杭州电子科技大学 HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1012
问题解析:
简单题,注意输出格式。引入<iomainip>头文件,调用setprecision()函数设置精度。
代码详解:
#include <iostream>
#include <iomanip>
#include <cstdio> using namespace std; int factorial(int); int main()
{
int i, n;
double e;
cout << "n" << " " << "e" << endl;
cout << "-" << " " << "-----------" << endl;
for(n=; n<=; n++) {
e = ;
for(i=; i<=n; i++) {
e += 1.0/factorial(i);
}
if(n < ) {
cout << n << " " << e << endl;
}else {
cout << fixed << setprecision() << n << " " << e << endl;
}
}
return ;
} int factorial(int n) {
if(n == ) {
return ;
}else {
return n * factorial(n-);
}
}
转载请注明出处:http://www.cnblogs.com/michaelwong/p/4287200.html
u Calculate e的更多相关文章
- [转] PHP计算两个坐标之间的距离, Calculate the Distance Between Two Points in PHP
Calculate the Distance Between Two Points in PHP There are a lot of applications where it is useful ...
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin ...
- maven -- 问题解决(二)解决“Could not calculate build plan”问题
错误提示如下:(eclipse+maven) Could not calculate build plan: Failure to transfer org.apache.maven.plugins: ...
- 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function
Calculate the Function Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...
- hdu 1012:u Calculate e(数学题,水题)
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Calculate its MTBF assuming 2000 FITS for each DRAM
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A common unit of meas ...
- u Calculate e 分类: HDU 2015-06-19 22:18 14人阅读 评论(0) 收藏
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- How to calculate a good InnoDB log file size
Peter wrote a post a while ago about choosing a good InnoDB log file size. Not to pick on Peter, b ...
- Calculate the formula
Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2. Input ...
- How to Calculate difference between two dates in C# z
Do you need to find the difference in number of days, hours or even minute between the two date rang ...
随机推荐
- qt界面不显示的原因
用qt designer弄了一个qq.ui 新建一个空项目,把qq.ui加入,新建一个qq类,qq.h如下 #ifndef QQ#define QQ #include <QMainWindow& ...
- CDZSC_2015寒假新人(1)——基础 f
Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u i ...
- 开发网站相关知识html和javascript
1.html 布局 https://github.com/bramstein/jlayout/ http://welcome.totheinter.net/columnizer-jquery-plug ...
- .Net Service部署(二)
1. 以管理员权限运行cmd.exe2. 安装服务 安装服务需要注意的是,如果电脑已经安装了此服务,需要先停止服务然后删除服务, 在进行安装注册,注册前先运行 cd C:\Windows\Micro ...
- Spring的注解学习(ioc,aop结合)
首先引入jar包 aspectjrt.jar aspectjweaver.jar 1.dao package com.dao; public interface OkpDao { public voi ...
- 学习《Javascript权威指南》的第二章笔记
1.Javascript区分大小写,但是HTML不区分大小写 2.JS会忽略标识之间的空格,多数情况下也会忽视换行符,所以要采用 整齐.一致的编码风格 3.//用作结尾的注释,/* 和 */可以当跨行 ...
- CentOS查看CPU、内存、网络流量和磁盘 I/O
安装 yum install -y sysstat sar -d 1 1 rrqm/s: 每秒进行 merge 的读操作数目.即 delta(rmerge)/swrqm/s: 每秒进行 merge 的 ...
- 测试框架mochajs详解
测试框架mochajs详解 章节目录 关于单元测试的想法 mocha单元测试框架简介 安装mocha 一个简单的例子 mocha支持的断言模块 同步代码测试 异步代码测试 promise代码测试 不建 ...
- Oracle EBS-SQL (INV-8):检查物料入库明细信息.sql
select a.vendor_number 供应商编码 ,a.vendor_name 供应商名称 ,a.item_nu ...
- 竹林蹊径-深入浅出Windows内核开发作者的博客
http://blog.csdn.net/blog_index http://blog.csdn.net/blog_index/article/details/6012054 http://downl ...