求1+1/1!+1/2!+1/3!+……1/m! 菜鸟等大神中…………
#include"stdio.h"doublefact(intp,intq);voidmain(){intm,i;doublef,sum=1;printf("please...
#include "stdio.h"
double fact(int p,int q);
void main ()
{
int m,i;
double f,sum=1;
printf("please input m:\n");
scanf("%d",&m);
for(i=1;i<=m;i++)
sum=sum+1/fact(i,m);
printf("fm is:%f",f);
}
double fact (int p,int q)
{
int a,n;
double power=1;
for(a=1;a<=n;a++)
power=power*a;
return power;
} 展开
double fact(int p,int q);
void main ()
{
int m,i;
double f,sum=1;
printf("please input m:\n");
scanf("%d",&m);
for(i=1;i<=m;i++)
sum=sum+1/fact(i,m);
printf("fm is:%f",f);
}
double fact (int p,int q)
{
int a,n;
double power=1;
for(a=1;a<=n;a++)
power=power*a;
return power;
} 展开
1个回答
展开全部
#include "stdio.h"
double fact(int n);
void main ()
{
int m,i;
double f,sum=1;
printf("please input m:\n");
scanf("%d",&m);
for(i=1;i<=m;i++)
sum=sum+1/fact(i);
printf("fm is:%7.4f",sum);
}
double fact (int n) {
int a;
double power=1;
for(a=1;a<=n;a++)
power=power*a;
return power;
}
double fact(int n);
void main ()
{
int m,i;
double f,sum=1;
printf("please input m:\n");
scanf("%d",&m);
for(i=1;i<=m;i++)
sum=sum+1/fact(i);
printf("fm is:%7.4f",sum);
}
double fact (int n) {
int a;
double power=1;
for(a=1;a<=n;a++)
power=power*a;
return power;
}
追问
#include "stdafx.h"
#include "stdio.h"
double fact(int p);
void main ()
{
int m,i;
double f,sum=1;
printf("please input m:\n");
scanf("%d",&m);
for(i=1;i<=m;i++)
sum=sum+1/fact(i);
printf("fm is:%7.4f",sum);
}
double fact (int p)
{
int a,n;
double power=1;
for(a=1;a<=n;a++)
power=power*a;
return power;
}
敢问这样的话,哪还错了
追答
{
int a,n;
double power=1;
for(a=1;a<=n;a++) // a<=n, n从哪来的?
power=power*a;
return power;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询