#include<stdio.h>
int main()
{
int n,i,m=-1;
double j=1,x;
printf("请输入n:\n");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
x=m*1.0/i;
j=j+x;
m=-m;
}
printf("%f\n",j);
return 0;
}
#include<stdio.h>
int main()
{
int n,i,m=-1;
double j=1,x;
printf("请输入n:\n");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
x=m*1.0/i;
j=j+x;
m=-m;
}
printf("%f\n",j);
return 0;
}