填空题已知递归函数f的定义如下:
int f(int n)
{
if(n<=1)return 1; //递归结束情况
else return n*f(n-2);//递归)
则函数调用语句f(5)的返回值是______。
填空题一个学生关系模式为(学号,姓名,班级号,…),其中学号为关键词:一个班级关系模式为(班级号,专业,教室,…),其中班级号为关键词:则学生关系模式中的外关键词为{{U}} 【4】 {{/U}}。
填空题下面程序运行时输出结果为{{U}} 【8】 {{/U}}。
#include<iostream.h>
#include<malloc.h>
class Rect
{
public:
Rect(int1,int w)(length=1;width=w;)
void Print(){cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size){return malloc(size);}
void operator delete(void *p){free(p)
private:
int length,width;
};
void main()
{
Rect*p;
p=new Rect(5,4);
p->Print();
delete p;
}
填空题继承的方式有公有继承、私有继承和{{U}} 【13】 {{/U}}种。
填空题下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整:
class complex
{
double real; //实部
double imag; //虚部
public:
complex( double r, double i):real(r),imag(i){}
complex operator + (complex a)
{
return complex({{U}} 【13】 {{/U}});
};
填空题若有定义语句:inta=3,b=2,c=1;,则表达式b<b?a:b的值是______。
填空题int k=10;float a=3.5,b=6.7,c; c=a+k%3*(int)(a+b)%2/4; 则c的值 【6】 。
填空题静态成员函数可以直接访问类的 【11】 成员,不能直接访问类的 【12】 成员。
填空题有以下程序:
#include <iostream>
using namespace std;
class sample
{
int x;
public:
void setx(int i)
{
x=i;
}
int putx ()
{
return x;
}
};
int main ( )
{
sample *p;
sample A[3];
A[0] .set>:(5);
A[1] .setx(6);
A[2] .setx(7);
for (int j=0;j<3;j++)
{
p=
cout<<p->putx () <<", ";
}
cout<<end1;
return 0;
}
执行后的输出结果是{{U}} 【14】 {{/U}}。
填空题有如下程序:
#include <iostream>
using namespace std;
class shapes
{
protected:
int x,y;
public:
void setvalue(int d, int w=0)
{
x=d;
y=w;
}
virtual void disp()=0;
};
class square : public shapes
{
public:
void disp()
{
cout<<x*y<<end1;
}
};
int main()
{
shapes *ptr;
square s1;
ptr=
ptr->setvalue(10,5);
ptr->disp();
return 0;
}
执行上面的程序将输出{{U}} 【14】 {{/U}}。
填空题执行语句: int result=100; cout<<(((result>= 60)结果是 【6】 。
填空题算法的基本特征是可行性、确定性、{{U}} 【3】 {{/U}}和拥有足够的情报。
填空题静态联编所支持的多态性称为编译时的多态性,动态联编所支持的多态性则称为运行时的多态性,动态多态性由{{U}} {{U}} {{/U}} {{/U}}来支持。
填空题重载的关系运算符和逻辑运算符的返回类型应当是______。
填空题语句cout<<setiosflags(ios::showpos)<<38<<""<<-38<<end1;的输出结果为______。
填空题以下程序的执行结果是 【11】 。#include<iostream.h>#include<stdlib.h>class Sample public: int x,y; Sample()x=y=0; Sample(int a,int b) x=a;y=b; void disp() cout<<"x="<<x<<",y="<<y<<end1; ;void main() Sample s1(2,3); s1.disp();
填空题结构化程序设计的一种基本方法是{{U}} 【3】 {{/U}}法。
填空题实现编译时多态性的机制称为______,实现运行时多态性的机制称为______。
填空题一棵二叉树有10个度为1的结点,7个度为2的结点,则该二叉树共有__【3】___个结点。
填空题某二叉树中度为2的节点有18个,则该二叉树中有{{U}} 【4】 {{/U}}个叶子节点。