已知函数Fact的程序如下,Fact(4)的值为_____。1.LongIntFact(intn)2.{LongIntx;3.If(n>1)4.{x=Fact(n-1);5.return(n+x)*2;}6.elsereturn1;7.}
44
举一反三
- 已知函数Fact的程序如下,在执行Fact(4)的过程中,Fact函数被调用的次数为_____。1. Long Int Fact(int n)2. { Long Int x;3. If (n > 1)4. { x = Fact(n-1);5. return (n+x)*2; }6. else return 1;7. }
- 已知函数Fact的程序如下,Fact(4)的值为_____。 1. Long Int Fact(int n) 2. { Long Int x; 3. If (n > 1) 4. { x = Fact(n-1); 5. return n*x; } 6. else return 1; 7. }
- 已知函数Fact的程序如下,在执行Fact(5)的过程中,Fact函数被调用的次数为_____。LongIntFact(intn){LongIntx;If(n>1){x=Fact(n-1);returnn*x;}elsereturn1;}? 3|5|6|4
- 已知函数Fact的程序如下,Fact(4)的值为_____。Long Int Fact(int n){Long Int x;If (n > 1) { x = Fact(n-1); return n*x; }else return 1; }? 15|120|24|10
- 中国大学MOOC:有如下递归函数fact(n),分析其时间复杂度为()。intfact(intn){if(n<=1)return1;elsereturn(n*fact(n-1));}
内容
- 0
28 有如下递归函数fact(n),其时间复杂度为( )。 int fact (int n) { if(n<=1) return 1; else return(n*fact(n-1)); }
- 1
以下计算阶乘n!的函数fact,正确还是错误?def fact(n) if n == 0 : return 1 else: return n * fact(n-1)
- 2
int fact(int n) { if ( n<=0) return 1 ; else return n*fact (n-1) ; } 则计算fact(n)需要调用该函数的次数为_____.
- 3
()设有一个递归算法如下 int fact(int n) { //n大于等于0 if(n<=0) return 1; else return n*fact(n-1); } 则计算fact(n)需要调用该函数的次数为( )
- 4
【填空题】下面程序段执行后,fact、sum的值分别是 、 int i,n,fact,sum; n=4; fact=1; sum=0; for(i=1;i<=n;i++) { fact=fact*i; sum+=fact; }