问题陈述:

  杭州电子科技大学 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的更多相关文章

  1. [转] 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 ...

  2. 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 ...

  3. maven -- 问题解决(二)解决“Could not calculate build plan”问题

    错误提示如下:(eclipse+maven) Could not calculate build plan: Failure to transfer org.apache.maven.plugins: ...

  4. 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function

    Calculate the Function Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...

  5. hdu 1012:u Calculate e(数学题,水题)

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. Calculate its MTBF assuming 2000 FITS for each DRAM

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A common unit of meas ...

  7. 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 ...

  8. 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 ...

  9. Calculate the formula

    Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input ...

  10. 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 ...

随机推荐

  1. php variance

    function variance ($a) { /** variable and initializations */ $the_variance = 0.0; $the_mean = 0.0; $ ...

  2. 【转】【可用】Android 登录判断器,登录成功后帮你准确跳转到目标activity

    我们在使用应用时肯定遇到过这样的情景,打开应用,并不是需要我们登录,你可以浏览应用中的大部分页面,但是当你想看某个详情页的时候,点击后突然跳转到了登录页面,好,我们输入账号密码,点击登录,登录成功,跳 ...

  3. ZRender源码分析2:Storage(Model层)

    回顾 上一篇请移步:zrender源码分析1:总体结构 本篇进行ZRender的MVC结构中的M进行分析 总体理解 上篇说到,Storage负责MVC层中的Model,也就是模型,对于zrender来 ...

  4. 【ecos学习3】redboot on vmware 网络配置

    需要图形化编译的时候必须 Build->Packages 加入:Common ethernet support 才可以有网络功能 导入vmare需要修改网络连接模式: 1- 设置redbootI ...

  5. How Many Tables(并查集)

    How Many Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. undefined reference to `_sbrk', `_write', `_lseek', `_read'

    现象: 在用GCC编译嵌入式MCU程序时,由于使用了第三方的库,出现了类似undefined reference to `_sbrk', `_write', `_lseek', `_read'的连接错 ...

  7. 跨域(cross-domain)访问 cookie (读取和设置)

    Passport 一方面意味着用一个帐号可以在不同服务里登录,另一方面就是在一个服务里面登录后可以无障碍的漫游到其他服务里面去.坦白说,目前 sohu passport 在这一点实现的很烂(不过俺的工 ...

  8. linux之普通用户与root用户之间切换

  9. 关于清晰讲解linux正则表达式的博文分享

    http://www.cnblogs.com/chengmo/archive/2010/10/10/1847287.html  linux shell 正则表达式(BREs,EREs,PREs)差异比 ...

  10. 【POJ 2823 Sliding Window】 单调队列

    题目大意:给n个数,一个长度为k(k<n)的闭区间从0滑动到n,求滑动中区间的最大值序列和最小值序列. 最大值和最小值是类似的,在此以最大值为例分析. 数据结构要求:能保存最多k个元素,快速取得 ...