#include
int main(void)
{
int flag=1,i,n,an;
float result=0;
printf("please input n:\n");
scanf("%n",&n);
for(i=1;i<=n;i++)
{
an=flag*(1.0)/i;
flag=flag*(-1);
result+=an;
}
printf("result:%f",result);
printf
}
加入头文件# include
double pow(double x,double y)用来求x的y次方