填空题
有以下程序:
#include <iostream>
using namespace std;
long fib( int n )
if ( n > 2 )
return ( fib( n - 1 ) + fib( n - 2 ) );
else
return 2;
int main ()
cout<<fib( 3 )<<endl;
return 0;
则该程序的输出结果应该是______。
【参考答案】
D
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
有以下程序 #include <iostream> using namespace std; class Base int a; public: Base(int x) a=x; void show() cout<<a; class Derived : public Base int b; public: Derived(int i) :Base(i+1),b(i) void show() cout<<b; ; int main () Base b(5),*pb; Derived d(1); pb=&d; pb->show (); return 0; 运行后的打印结果是______。
点击查看答案&解析
填空题
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用;请补充完整。 class complex private: int real; int imag; public: complex(int r=0,int i=0):real(r),imag(i) void show () cout<<real<<(imag<0 - : + )<<imag<<’i’; ______; ; complex& operator -- (complex &c) c.real --; return c;
点击查看答案&解析
相关试题
设树T的度为4,其中度为1,2,3,4的...
下列关于构造函数的描述中,错误的是
在下面的运算符重载函数的原型中,错误的是
下列对于线性链表的描述中正确的是
对于语句cout<<endl<<x;中的各个组成...