zoukankan      html  css  js  c++  java
  • OpenJudge/Poj 1517 u Calculate e

    1.链接地址:

    http://bailian.openjudge.cn/practice/1517

    http://poj.org/problem?id=1517

    2.题目:

    总时间限制:
    1000ms
    内存限制:
    65536kB
    描述
    A simple mathematical formula for e is
    e=Σ0<=i<=n1/i!

    where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.
    输入
    No input
    输出
    Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.
    样例输入
    no input
    样例输出
    n e
    - -----------
    0 1
    1 2
    2 2.5
    3 2.666666667
    4 2.708333333
    ...
    来源
    Greater New York 2000

    3.思路:

    4.代码:

     1 #include "stdio.h"
     2 //#include "stdlib.h"
     3 int main()
     4 {
     5     int tmp=1;
     6     double sum=1;
     7     int i=0;
     8     printf("n e
    ");
     9     printf("- -----------
    ");
    10     printf("%d %.10g
    ",i,sum);
    11     for(i=1;i<10;i++)
    12     {
    13        tmp*=i;
    14        sum+=(double)1/tmp;
    15        printf("%d %.10g
    ",i,sum);
    16     }
    17     //system("pause");
    18     return 0;
    19 }
  • 相关阅读:
    windows 杀进程
    tool
    转:TestLink1.9.3测试用例:Excel转换XML工具<二>实现代码
    转:Excel转换XML工具<一>
    testlink 下载地址
    testng xml 示例
    eclipse中使用loadrunner java api步骤
    mybatis入门例子
    myBatis的引出
    maven
  • 原文地址:https://www.cnblogs.com/mobileliker/p/3558480.html
Copyright © 2011-2022 走看看