用C语言求1到n的阶乘和,你想不到的神奇效果

更新时间:01-31 教程 由 凉人心 分享

的阶乘和呢?代码如下

```clude

tain() {t = 0, factorial = 1;tf");f);; i++) {

factorial = 1;

for (j = 1; j<= i; j++) {

factorial = j;

} += factorial;

}tf); 0;

表示阶乘和,factorial表示当前循环变量i的阶乘。代码如下

```clude

tt) { == 1) { 1;

} else { - 1);

}

tain() {t = 0;tf");f);; i++) { += factorial(i);

}tf); 0;

-1的阶乘。而且,通过这个例子,我们也可以看到C语言的强大之处。在编写程序时,我们可以根据实际情况选择不同的算法来实现同样的功能。

声明:关于《用C语言求1到n的阶乘和,你想不到的神奇效果》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2127222.html