用C语言求s=1-1/2!+1/3!-1/4!+……+1/n!其中n的值由键盘输入(急!!)
用C语言求s=1-1/2!+1/3!-1/4!+……+1/n!其中n的值由键盘输入(急!!)
日期:2020-12-26 13:54:41 人气:1
#include
double factorial(int n)
{
double f = 1 ;
for (int t=1 ; t<= n ; t++)
{
f = f*t ;
}
return f;
}
void main()
{
int n, k=1;
double s = 0 ;
printf("Input n\nn=") ;
scanf("%d", &n) ;
for (int t=1; t<=n; t++)
{
s = s + ((