haha1235  

#include<stdio.h>
int main(void)
{
    int denominator,flag,i,n;
    double item,sum;
    printf("Enter n:");
    scanf("%d",&n);
    flag=1;
    denominator=1;
    sum=0;
    for(i=1;i<=n;i++){
    item=flag*1.0/denomintor;
    sum=sum+item;
    flag=-flag;
    denominator= denominator+2
    }
    printf("sum=%f\n",sum);
    return 0;
}

posted on 2013-10-07 10:57  haha1235  阅读(104)  评论(0编辑  收藏  举报