标签:
Description
Output
Sample Output
#include<iostream> #include<iomanip> using namespace std; double f(int n) { long double a=1; for(int i=1;i<=n;i++)a*=i; return a; } int main() { cout << "n e"<<endl<<"- -----------"<<endl; double e=1; cout<<0<<" "<<e<<endl; for(int i=1;i<=9;++i) { e+=1/f(i); cout<<i<<" "; if(i!=8) cout<<setprecision(10)<<e<<endl; else cout<<setprecision(10)<<e<<0<<endl; } //system("pause"); return 0; }
不难!!不要忘了long double !!!!
标签:
原文地址:http://www.cnblogs.com/farewell-farewell/p/5167299.html