填空题
下面是用来计算n的阶乘的递归函数,请将该函数的定义补充完整。(注:阶乘的定义是n!cn*(n-1)*...*2*1)
unsigned fact(unsigned n)
if (n<=1)
return 1;
return
【12】
;
【参考答案】
n*fact(n-1)或者fact(n-1)*n或者n*fact(-1+n)或者fact(-1+n)*n
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
与成员访问表达式p→name 等价的表达式是 【14】 。
点击查看答案&解析
填空题
下列程序的输出结果是 【11】 。 #include <iostream> using namespace std; class Test public: Test() cnt++; ~Test() cnt--; static int Count() (return cnt; private: static int cnt; ; int Test::cnt=0; int main() cout<<Test::Count()<<’’; Test t1, t2; Test *pT3=new Test; Test *pT4=new Test; cout<<Test::Count()<<’’; delete pT4; delete pT3; cout<<Test::Count()<<end 1; return 0;
点击查看答案&解析
相关试题
下列程序输出结果是 【13】 。 includ...
下列程序的输出结果是 【15】 。 #in...