填空题

下面是用来计算n的阶乘的递归函数,请将该函数的定义补充完整。(注:阶乘的定义是) n!=n*(n-1)*...*2*1)
unsigned fact(unsigned n)

if (n <=1)
return 1;
return______;

【参考答案】

n*fact(n-1)
<上一题 目录 下一题>
热门 试题

填空题
以下程序运行后的输出结果是______。 #include <iostream> #include <string> using namespace std; class Y; class X int x; char *strx; public: X(int a, char *str) x=a; strx=new char[strlen(str)+1] strcpy (strx,str); void show(Y &ob); ; class Y prlvate: int y; char *stry; public: Y(int b,char *str) y=b; stry=new char[strlen(str)+1]; strcpy(stry,str); friend void X::show(Y &ob); ; void X::showY &ob) cout<<strx<< , , cout<<ob.stry<<endl; int main X a (10, stringX ); Y b (20, stringY ); a. show (b); renurn 0;
填空题
请按下面注释的提示,将类B的构造函数定义补充完整。 classA int a; public: Aint aa=0) (a=aa; class B:public A int b; A c; public: 用aa初始化基类A,用aa+1初始化类对象成员c B(int aa): b=aa+2 ;
相关试题
  • 下面程序的输出是: **********...
  • 下列程序的输出结果是______。 #in...
  • 设在主函数中有以下定义和函数调用语句,且...
  • 在下面横线上填上适当的语句,完成程序。 ...