编写程序计算 s = 1 + 1 / 2! + 1 / 3! + 1 / 4! + … + 1 / n!,
n由终端输入,将计算n!定义成函数。
(要求定义函数sum求和,在函数sum中调用n!的函数求加数)
代码如下
#include<stdio.h>
#include<stdlib.h>
int fac(int n) //阶乘函数
{
int i = 0;
编写程序计算 s = 1 + 1 / 2! + 1 / 3! + 1 / 4! + … + 1 / n!,
n由终端输入,将计算n!定义成函数。
(要求定义函数sum求和,在函数sum中调用n!的函数求加数)
代码如下
#include<stdio.h>
#include<stdlib.h>
int fac(int n) //阶乘函数
{
int i = 0;