问题陈述:

  杭州电子科技大学 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. HAProxy+Keepalived+PXC负载均衡和高可用的PXC环境

    HAProxy介绍 反向代理服务器,支持双机热备支持虚拟主机,但其配置简单,拥有非常不错的服务器健康检查功能,当其代理的后端服务器出现故障, HAProxy会自动将该服务器摘除,故障恢复后再自动将该服 ...

  2. java 简单的文件上传

    一.文件上传原理: 1.文件上传的前提: a.form表单的method必须是post b.form表单的enctype必须是multipart/form-data(决定了POST请求方式,请求正文的 ...

  3. ecshop简单结构

    Ecshop包括的文件夹有admin.api.cert.data.images.includes.js. languages.plugins.temp.theme.wap.widget这些文件夹,和根 ...

  4. Python之路第八天,基础(10)-异常处理

    异常处理 1. 异常基础 python3 try: pass except Exception as ex: pass while True: num1 = input('num1:') num2 = ...

  5. MYSQL 提取时间中的信息的 4 方法

    方法 1. year(),month(),day() 方法 2. dayofweek(),dayofmonth(),dayofyear(); 方法 3. hour(),minute(),second( ...

  6. Jquery一个slideToggle搞定div的隐藏与显示

    Jquery一个slideToggle搞定div的隐藏与显示 <!DOCTYPE html> <html> <head> <script src=" ...

  7. Oracle监控指标

    1.数据文件或数据设备 参考:http://f.dataguru.cn/thread-106901-1-1.html2.数据库日志空间活或回滚段(包括大小.设备.文件及可用率.日志空间竞争情况或回滚段 ...

  8. YY的困境:除了终止私有化 还有更多的担忧

    界面 刘莎 已大热一段时间的中概股私有化浪潮随着中国股市的下跌而降温,很多在美上市的中概股不得不因此叫停私有化,欢聚时代(下称YY)首当其冲,成为私有化大军中首个被迫撤退的中资公司. 虽然从表面看,私 ...

  9. Android doGet方法

    DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://w ...

  10. 【POJ 3009 Curling2.0 迷宫寻径 DFS】

    http://poj.org/problem?id=3009 模拟冰壶的移动,给出到达终点的最少投掷次数(不可达时为-1). 具体移动规则如下: 每次选四个方向之一,沿此方向一直前进,直到撞到bloc ...