ZOJ 1113 u Calculate e

来源:互联网 发布:java程序员买书 编辑:程序博客网 时间:2024/05/21 22:44

纯水题。

时间:0毫秒。

#include<iostream>#include<iomanip>using namespace std;int main(){    double ans=1, temp=1;    int i=0;       cout<<"n e"<<endl;    cout<<"- -----------"<<endl;    cout<<i<<' '<<ans<<endl;    for(i=1; i<=9; ++i)    {        temp/=i;        ans+=temp;        if(i<3) cout<<setprecision(9);        else    cout<<fixed<<setprecision(9);        cout<<i<<' '<<ans<<endl;    }       return 0;}


0 0
原创粉丝点击