05-0. 求序列前N项和(15)

来源:互联网 发布:软件多开器电脑版 编辑:程序博客网 时间:2024/05/16 10:55

05-0. 求序列前N项和(15)

#include <stdio.h>void ttt(double *a, double *b){        double tmp;        tmp = *a;        *a = *a + *b;        *b = tmp;}int main(){        double a, b, h;        int c;        scanf("%d", &c);        h = 0;        a = 1.0;        b = 2.0;        for (; c > 0; c--)        {                h += (b / a);                ttt(&b, &a);        }        printf("%0.2f", h);}


0 0
原创粉丝点击