- #include<string>
- #include<iostream>
- #include<iomanip>
- using namespace std;
- double fun(int n)
- {
- double back = 1.0;
- for(int i = 1;i < n;i++)
- back = back * double(i);
- return back;
- }
- int main()
- {
- cout<<"n"<<" "<<"e"<<endl;
- cout<<"-"<<" "<<"-----------"<<endl;
- for(int i = 0;i < 10;i++)
- {
- double e = 0;
- for(int j = 0;j <= i;j++)
- e = e + 1.0 / fun(int(j+1));
- if(i == 0||i == 1||i == 2) cout<<i<<" "<<e<<endl;
- else if(i != 8){
- cout<<i<<" "<<setprecision(10)<<e<<endl;
- }
- else{
- cout<<i<<" "<<e<<"0"<<endl;
- }
- }
- return 0;
- }
u Calculate e
最新推荐文章于 2022-10-29 15:48:58 发布