有点小问题2??!
#include "stdio.h" #include "math.h"
main() {double tsum=0.0; int n=1,k,a,sum,j=-1,d=1; printf("Please input n:"); scanf("%d",&a); sum=3; for(k=2;n<a;n++) {k=k*2; sum=sum+k;} printf("\n%d",sum);
for(;d<=(int)(sqrt(sum));d++) {j=-j; tsum=tsum+j*(1/(d)); } printf("\n%f",tsum);
}
想问问为甚么tsum的值不变啊??按道理来说应该是1-(1/2)+(1/3)-(1/4)……(-1)^(k+1)*(1/k)啊