标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 37350 Accepted Submission(s):
16905
#include<stdio.h> #include<string.h> double b[20]; double fun(int x) { int i; double sum=1.0,a=1.0; for(i=1;i<=x;i++) { sum=a*sum; a=a+1; } sum=1/sum; return sum; } int main() { int n,m,j,i; double sum=0; b[0]=1;b[1]=1; for(i=2;i<=9;i++) b[i]=fun(i); printf("n e\n"); printf("- -----------\n"); for(i=0;i<=9;i++) { printf("%d ",i); sum+=b[i]; if(i==2) { printf("2.5\n"); continue; } if(sum==(int)(sum)) printf("%d\n",(int)(sum)); else printf("%.9lf\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4910996.html