求分数序列前N项和

#include <stdio.h>

int main()
{
    int  i, n;
    double numerator, denominator, item, sum, swap;
    while (scanf("%d", &n) != EOF)
    {
        numerator = 2;
        denominator = 1;
        item = 0;
        sum = 0;
        for (i = 1; i <= n; i++)
        {
            item = numerator/denominator;
            sum = sum + item;
            swap = numerator;
            numerator = numerator+denominator;
            denominator = swap;
        }
        printf("%.2f\n", sum);
    }
    return 0;
}

39. 求分数序列前N项和的更多相关文章

  1. 20. 求阶乘序列前N项和

    求阶乘序列前N项和 #include <stdio.h> double fact(int n); int main() { int i, n; double item, sum; whil ...

  2. 19. 求平方根序列前N项和

    求平方根序列前N项和 #include <stdio.h> #include <math.h> int main() { int i, n; double item, sum; ...

  3. noi 求分数序列和 x

    求分数序列和 总时间限制:  1000ms 内存限制:  65536kB 描述 有一个分数序列 q1/p1,q2/p2,q3/p3,q4/p4,q5/p5,.... ,其中qi+1= qi+ pi, ...

  4. 11. 求奇数分之一序列前N项和

    求奇数分之一序列前N项和 #include <stdio.h> int main() { int denominator, i, n; double item, sum; while (s ...

  5. 10. 求N分之一序列前N项和

    求N分之一序列前N项和 #include <stdio.h> int main() { int i, n; double item, sum; while (scanf("%d& ...

  6. 循环-10. 求序列前N项和*

    /* * Main.c * C10-循环-10. 求序列前N项和 * Created on: 2014年7月30日 * Author: Boomkeeper *******部分通过******* */ ...

  7. 练习2-14 求奇数分之一序列前N项和 (15 分)

    练习2-14 求奇数分之一序列前N项和 (15 分) 本题要求编写程序,计算序列 1 + 1/3 + 1/5 + ... 的前N项之和. 输入格式: 输入在一行中给出一个正整数N. 输出格式: 在一行 ...

  8. 练习2-13 求N分之一序列前N项和 (15 分)

    练习2-13 求N分之一序列前N项和 (15 分) 输入在一行中给出一个正整数N. 输出格式: 在一行中按照“sum = S”的格式输出部分和的值S,精确到小数点后6位.题目保证计算结果不超过双精度范 ...

  9. OpenJudge计算概论-求分数序列和

    /*======================================================================== 求分数序列和 总时间限制: 1000ms 内存限制 ...

随机推荐

  1. SQL 查询45题

    表格代码 create table student ( sno ) primary key, sname ) not null, ssex ) not null, sbirthday datetime ...

  2. Snmp配置

    http://www.07net01.com/linux/CentOSxiaSNMPfuwuanzhuang_496848_1372907142.html

  3. poj 1236 scc强连通分量

    分析部分摘自:http://www.cnblogs.com/kuangbin/archive/2011/08/07/2130277.html 强连通分量缩点求入度为0的个数和出度为0的分量个数 题目大 ...

  4. MySQL监控系统MySQL MTOP的搭建

    MySQLMTOP是一个由Python+PHP开发的MySQL企业级监控系统.系统由Python实现多进程数据采集和告警,PHP实现WEB展示和管理.最重要是MySQL服务器无需安装任何Agent,只 ...

  5. ubuntu 重置密码

      背景:在登陆ubuntu之后,按Ctr+Alt+F1进入控制台时,需要登陆,一时忘了密码... 参考:http://www.cnblogs.com/relaxgirl/p/3179507.html ...

  6. HDU4812 D Tree(树的点分治)

    题目大概说给一棵有点权的树,输出字典序最小的点对,使这两点间路径上点权的乘积模1000003的结果为k. 树的点分治搞了.因为是点权过根的两条路径的LCA会被重复统计,而注意到1000003是质数,所 ...

  7. DelPhi学习网站

    http://www.2ccc.com/downloads.asp?subcatalogid=101&pageid=14 http://www.2ccc.com/ http://www.xue ...

  8. 2015ACM/ICPC亚洲区长春站 J hdu 5536 Chip Factory

    Chip Factory Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  9. extjs 2.0获取选中的radio的值

    var temp=winFormPanel.getForm().findField('selectedType').getGroupValue();

  10. 浅谈MySQL索引背后的数据结构及算法

    摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...