如题所述
#include <stdio.h>
void main()
{
int n,i;
float s=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
s += 1.0 / (i * (i + 1));
printf("前%d项和为:%.6f",n,s);
}