65,211
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
#include <iomanip>
using namespace std;
double cou(int n){
int i,j;
double z=0.0,temp;
if(n==0) return 1;
for(i=n;i>0;i--){
temp=1.0;
j=i;
while(j!=0){
temp *=1.0/j;
j--;
}
z +=temp;
}
z+=1;
return z;
}
int main()
{
double z;
cout<<"n e"<<endl;
cout<<"- -----------"<<endl;
for(int i=0;i<=9;++i){
z=cou(i);
cout<<i<<' '<<setw(11)<<setprecision(9)<<setiosflags(ios::left)<<z<<endl;
}
return 0;
}