标题:
汉语程序与c语言程序递归 之比较
[打印本页]
作者:
liumei
时间:
2014-4-22 15:54
标题:
汉语程序与c语言程序递归 之比较
编 平方 ♂ * 。
编 求自然数平方和 ( n --- n1 )
♂ 0 >
就
♂ 平方 ↑↓ 1- 递归 +
然后
。
long fact(int n)
{
long s;
if(n<=1)
s=0;
else
s=n*n+fact(n-1);
return s;
}
编 阶乘 ( n --- n1 )
♂ 1 >
就
♂
1- 递归 *
然后
。
long fact(int n)
{
long s;
if(n<=1)
s=1;
else
s=n*fact(n-1);
return s;
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1