欲求1-1/2+1/3-1/4............,但我写错了,谁帮我改啊
#include "stdio.h"double mycount(int);
main()
{ int a ;
double add;
add=0.0;
printf("intput n:\n");
scanf("%d",&a);
add=mycount(a);
printf("%lf\n",add);
}
double mycount(int a)
{ double t,add;
int s,k;
s=-1;
for(k=1;k<=a;k++)
{t=s/(-k);
add+=t;
s=s*(-1);
return add;
} 当a=10时,结果是0.645635.但我并没得到我想要的结果
}