Problem : 1012 ( u Calculate e ) Judge Status : Accepted
RunId : 7741966 Language : C Author : qq1203456195
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
1 #include<stdio.h> 2 void main() 3 { 4 int n=0; 5 double e=1,t=1;//t记录阶乘 6 char str[65]; 7 printf("n e\n"); 8 printf("- -----------\n"); 9 while(n<=9) 10 { 11 printf("%d ",n); 12 switch(n) 13 { 14 case 0: 15 case 1: 16 printf("%.0lf\n",e); 17 break; 18 case 2: 19 printf("%.1lf\n",e); 20 break; 21 default: 22 printf("%.9lf\n",e); 23 break; 24 } 25 t*=++n; 26 e += 1.0/t; 27 } 28 }