#include
int main()
{
int n;
int flag = -1;
double sum = 0;
printf(“请输入n=”);
scanf("%d".&n);
for(int i=0;i{
flag *= -1;
sum += flag/(n+1);
}
printf(“sum= %f”,sum);
}
#include
int main()
{
double a = 1-1.0/2+1.0/3-1.0/4+1.0/5-1.0/6;
printf("%lf\n", a);
return 0;
}
你这个应该是求double型的