hdu-1012-u Calculate e(水题)
1 #include <iostream> 2 using namespace std; 3 int main() { 4 int jiecheng[10]; 5 jiecheng[0] = jiecheng[1] = 1; 6 for (int i=2; i<10; i++) { 7 jiecheng[i] = jiecheng[i-1] * i; 8 } 9 printf("n e\n"); 10 printf("- -----------\n"); 11 printf("0 1\n"); 12 printf("1 2\n"); 13 printf("2 2.5\n"); 14 double num[10]; 15 num[2] = 2.5; 16 for (int i=3; i<10; i++) { 17 num[i] = 1.0/jiecheng[i] + num[i-1]; 18 printf("%d %.9lf\n", i,num[i]); 19 } 20 return 0; 21 }