您的位置:首页 > 其它

【poj 1517】 u Calculate e

2016-10-18 13:11 330 查看

题意:

n从0到9时,计算e的值分别是多少。

思路:

模拟即可。

代码:

#include <iostream>
#include <cstdio>
using namespace std;
typedef double db;
int main(){
printf("n e\n- -----------\n");
printf("0 1\n");
db now = 1, ans = 1;
for(int i = 1; i <= 9; i ++, now*=i)
ans += 1/now, printf("%d %.9f\n", i, ans);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  poj 模拟