标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36110 Accepted Submission(s): 16298
1 #include <stdio.h> 2 double add(double t) 3 { 4 double s=1; 5 int i; 6 if(t==0) //0!=1 7 return 1; 8 for(i=1; i<=t; i++) //求n! 9 s*=i; 10 return s; 11 } 12 int main() 13 { 14 double e=0; 15 int i,j; 16 printf("n e\n"); 17 printf("- -----------\n"); 18 printf("0 1\n"); 19 for(i=1; i<=9; i++) 20 { 21 e=0; 22 for(j=0; j<=i; j++) 23 e=e+1/add(j); 24 if(i<=2) //输出需要分开讨论 25 printf("%d %lg\n",i,e) ; 26 else 27 printf("%d %.9lf\n",i,e) ; 28 } 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/4760739.html