hdu_1012

来源:互联网 发布:电脑语音读书软件 编辑:程序博客网 时间:2024/06/10 20:43
#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;   for(int n=3;n<=9;n++)   {       long double e=2.0;       for(int j=2;j<=n;j++)       {           int buffer=1;           for(int k=1;k<=j;k++)            buffer=buffer*k;           e=e+1.0/((long double)buffer);       }       cout<<n<<' ';       cout.setf(ios::fixed);       cout<<setprecision(9)<<e<<endl;   }   return 0;}

0 0
原创粉丝点击