Posted on 2008-04-06 20:33
superman 阅读(363)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1113 C++ 00:00.00 832K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 cout << "n e" << endl
9 << "- -----------" << endl;
10
11 cout.setf(ios_base::showpoint);
12 cout.setf(ios_base::fixed);
13
14 double e = 0;
15 for(int n = 0; n < 10; n++)
16 {
17 int i = 1;
18 for(int k = 1; k <= n; k++)
19 i *= k;
20 e += 1.00 / i;
21 cout << n << ' ';
22 if(n < 2)
23 {
24 cout << int(e) << endl;;
25 continue;
26 }
27 if(n == 2)
28 cout.precision(1);
29 if(n == 3)
30 cout.precision(9);
31 cout << e << endl;
32 }
33
34 return 0;
35 }
36