码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1012 u Calculate e

时间:2014-08-04 14:00:57      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   color   os   strong   io   for   c   ios   

#include<iostream>

#include<iomanip>

using namespace std;

int main(){
cout << "n" << ‘ ‘ << "e" << endl;
cout << "-" << ‘ ‘ << "-----------" << endl;
cout << 0 << ‘ ‘ << 1 << endl;
cout << 1 << ‘ ‘ << 2 << endl;
cout << 2 << ‘ ‘ << 2.5 << endl;
long double sum = 2.5;
long double a = 1;
for (int i = 3; i <= 9; i++){
long double temp = 1;
for (int j = 1; j <= i; j++)
temp *= j;
sum += a/ temp;
cout << i << ‘ ‘ << setiosflags(ios::fixed) << setprecision(9) << sum << endl;
}
return 0;
}

hdu 1012 u Calculate e,布布扣,bubuko.com

hdu 1012 u Calculate e

标签:style   color   os   strong   io   for   c   ios   

原文地址:http://www.cnblogs.com/caiyonghai/p/cug.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!