题目地址 :多项式求和
/* #include<stdio.h> int main() { int n,b; double a[110],x; double z; int i,j; int f; for (i=1;i<101;i++) a[i]=(double)1/(double)i; scanf("%d",&n); while(n--) { scanf("%d",&b); z = 0; f = 1; //printf("%d ",b); for (i=1;i<=b;i++) { x = f*a[i]; z = z+x; f = -1*f; } printf("%.2lf ",z); } return 0; } */ /* #include<stdio.h> int main() { float a[110]; int i,f,n,c; f = 1; a[0]=0; for (i=1;i<101;i++) { a[i]=a[i-1]+f*1.0/(float)i; f=-f; } scanf("%d",&n); for (i=0;i<n;i++) { scanf("%d",&c); //printf("%d ",b); printf("%.2f ",a[c]); } return 0; } */ #include<stdio.h> int main() { int a[110]; double x,s; int i,n,m,j,f; scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d",&a[i]); for (i=1;i<=n;i++) { f = 1; s = 0; for (j=1;j<=a[i];j++) { s=s+1.0/j*f; f=-f; } printf("%.2f ",s); } return 0; }