编写C程序,利用公式e=1+1/1!+1/2!+1/3!+ +1/n!,求的近似值,其中有用户输入。 +

日期:2010-05-28 11:08:27 人气:3

编写C程序,利用公式e=1+1/1!+1/2!+1/3!+ +1/n!,求的近似值,其中有用户输入。 +

我来答 #include void main() { int n; float a=1,sum=1; printf("请输入n:"); scanf("%d",&n); for(int i=1;i<=n;i++){ a=a*i; sum=sum+1/a; } printf("sum=%f",sum); printf("\n"); }
    A+
热门评论