填空题在对一组记录(54,38,96,23,15,72,60,45,83)进行直接插入排序时,当把第7个记录60插入到有序表时,为寻找插入位置需比较______次。
填空题 【11】 是实现C++语言编译时多态性的机制, 【12】 是实现C++语言运行时多态性的机制。
填空题C++语句const char * const p= "hello";,所定义的指针p和它所指的内容都不能被 【10】 。
填空题若有: int x=25,y=14,z=19; 则在计算表达式x++<=25&&y--<=2&&++z<=18后,z的值为 [6] 。
填空题常量和变量的区别是:常量在程序运行中值不变,因此它的值在定义时便进行初始化;而尘量的值是可以改变的, 【6】 类型的变量存储的是变量的地址。
填空题若a=12,b=14,c=0,则表达式“((y=(a>B) ?a:B) >C) ?y:c”的值为{{U}} 【6】 {{/U}}。
填空题设有定义语句:double x=2.5, y=4.7;int a=7;那么表达式x+a%3*(int)(x+ y)%2/4的值为
________
。
填空题有如下程序:#include<iostream.h>void main()int x=2,y=3,a,b,c,d;a=(x++>=--y);b=(x==++y);c=(x--!=y);d=(++x>y--);Cout<<a<<b<<c<<d<<end1;则程序执行后变量a,b,c,d的值分别是 【12】 。
填空题在双链表中,每个节点有两个指针域,一个指向前驱节点,另一个指向 【2】 。
填空题下面f函数的功能是将形参x的值转换成二进制数,所得二进制数的每一位数放在一维数组y中返回。二进制的最低位放在下标为0的位置上。请将横线处的程序补充完整。
void f(int x,int y[])
{
int a=0,b;
do
{
b=x% ______;
y[a++]=b;
x/=2;
} while(x);
}
填空题假设int a=1,b=2;,则表达式(++a/b)*b--的值为【 】。
填空题下面程序的运行结果为 【10】 。 #include<iostream.h> void fun(intx=0,iot y=0) cout<<X<<y; Void main() fun(5);
填空题数组的下标是从{{U}} 【6】 {{/U}}开始的。
填空题设二叉树根结点的层次为0,对含有100个结点的二叉树,可能的最大树深和最小树深分别是______。
填空题执行如下程序后的输出结果是{{U}} 【15】 {{/U}}。
#include <iostream>
#include <fstream>
using namespace std;
int main ( )
{
char s[25];
ofstream fl("data.txt");
f1<<"C++ Programming";
f1.close ();
ifstream f2 ("data.txt");
if (f2.good()) f2>>s;
f2.close();
cout<<s;
return 0;
}
填空题有如下程序:
#include<iostream>
using namespace std;
class Sac{
int n;
public:
Sac():n(4){cout<<n;}
Sac(int k):n(k){cout<<n;}
~Sac(){cont<<n+n;}
};
int main(){
Sac s1,*s2;
s2=new Sac(3);
delete s2;
return 0;
}
运行时的输出结果是___【11】___。
填空题下列程序编译错误,因为add函数返回值是一个引用,故对return返回值的要求是______。 #included<iostream.h> int & add(int x,int y) return x+y; void main() int i=3,j=19; cout<<(add(i,j)+=20)<<endl;
填空题有以下程序:
#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)
void show() { cout<<b; }
};
int main ( )
{
Base b(5) ,*pb;
Derived d(1);
pb=
pb->show ();
return 0;
}
运行后的打印结果是
________
。
填空题有以下程序 #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; 则该程序的输出结果应该是______。
填空题重载的流运算符函数经常定义为类的______函数。
