zzuli OJ 1040:数列加算1


Description
整数nを入力し、1+1/3+1/5+......前のn項の和を出力します.
Input
入力は正の整数nが1つしかありません.
Output
結果保留2は小数で、単独で1行を占めます.
Sample Input
3
Sample Output
1.53
HINT
Source
#include<stdio.h>

int main()
{
    int i, n;
    double sum, deno;

    scanf("%d", &n);
    sum = 0.0;
    deno = 1.0; //          

    for(i = 1; i <= n; i++) //  n 
    {
        sum += 1.0 / deno;  //        
        deno += 2;        //       
    }

    printf("%.2f
", sum); return 0; }