标签:
#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/denominator;
sum=sum+item;
flag=flag;
denominator=denominator+1;
}
printf("sum=%f\n",sum);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/160809112lty/p/5920459.html