填空题对于下列语句
char* strl = "Hello";
char * str2 =. "Hello";
*strl = 'P';
cout<<str2<<end1;
其输出结果为:{{U}} 【8】 {{/U}}
填空题下面程序实现输出从“!”开始的91个ACCII字符及码值,要求每行输出7项。请完成程序。 #include<iostream.h> void main( ) char c= "!"; int d , n=1; do while (n<=7) d=c; cout<<c<< "=" <<d<<“”; c++ n++; cout<< "/n" ; [7] ; while(c<= '!' +90) cout<< "/n" ;
填空题设树T的度为4,其中度为1,2,3,4的结点个数分别为4,2,1,1,则T中的叶子结点数为 【5】 。
填空题指出下面程序段中的错误,并说明出错原因{{U}} [13] {{/U}}。
class Location {
int X, Y=20;
protected:
int zeroX, zeroY;
int SetZero(int ZeroX, iht ZeroY);
private:
int length, height;
public:
float radius;
void init(int initX,int initY);
int GetX();
Int GetY();
};
填空题类time可以输出12小时或24小时制的时间,现需要设计一个缺省构造函数,缺省值为0时0分0秒。该缺省构造函数为{{U}} 【14】 {{/U}}。
# include<iostream. h>
class Time
{
int h.m,s;
public:
Time(int hour=0 .int min=0 ,int sec=0) {settime(hour,min,sec);}
void settime(int hour,int min,int sec) {h=hour; m=min s=sec;}
void show24()
{ cout<<(h<1O?"0":"")<<h<<":"<<(m<10?"0":"")<<
m<<":"MM(s<10?"0":"")<<s<<end1
}
void show12( )
{ int temp=(h==‖h==12)? 12:h%12;
cout<<(temp<10?"0":"")<<temp<<":"<<(m<10?"0":"")
<<m<<":"<<(s<10? "0":"")<<s<<((temp>0
void main()
{
Time t(15,43,21)
t. show12():
t. show24()
}
填空题有如下程序: #include<iostream> using namespace std; class Base public; int m,n; ; class Derived1:______Base; class Derived2:public Derivedl public: void SetMN(int M,int N)m=M;n=N; int GetSumMN()return(m+n); ; int main() Derived2 objD; objD.SetMN(3,4); cout<<"M+N="<<objD.m+bojD.n<<endl; return 0: 编译时只有"cout<<"M+N="<<objD.m+bojD.n<<endl;”有语法错误,程序的其他地方没有语法错误, 请判断横线处使用的关键字是______。
填空题C++中封装性、继承性和{{U}} {{/U}}是面向对象思想的主要特征。
填空题设i、j、k均为int型变量,则执行完for(i=0,j=10;i<=j;i++,j--) k=i+j;语句后,k的值为
______
。
填空题下面程序的输出结果为{{U}} 【6】 {{/U}}。
#include <iostream>
using namespace std;
void initialize(int printNo, int state=0);
void initialize(iht printNo= 1,int state);
int main()
{
initialize();
return 0;
}
void initialize(int printNo, int state)
{
cout<<printNo<<","<<state<<end1;
}
填空题在测试时,完全不考虑程序的内部结构和内部特征的测试方法称为{{U}} 【4】 {{/U}}测试方法。
填空题下列程序的执行结果是{{U}} 【12】 {{/U}}。
#include < iostream. h>
class Myclass
{
public:
void GetSum(int a)
static int Sum:
private:
int A;
};
int Myclass:: Sum =10; //必须在类外部对静态数据成员初始化
void Myelass: :GetSum(int a)
{
A=a;
Sum+=A;
}
void PrintSum(Myclass
}
void main( )
{
Myclass M,N;
M. GetSum(3)
N. GetSum(7)
PrintSum(M);
}
填空题下列程序在输入m后,求满足条件“n!<=m<=(n+1)!”的值n,请将程序补充完整。 #include <iostream> using namespace std; int main() int n,m, jc = 1; cin>>m; for(n=2;jc<=m;n++) jc = jc*n; cout<<"n="<< 【6】 <<end1; return 0;
填空题下面程序的运行结果是 8 和 9 。 #include<iostream.h> #define N 10 #define s(x) x * x #define f(x) (x * x) void main( ) int i1,i2; i1=1000/s(N) ;i2=1000/f(N) ; cout < < i1 < < " " < < i2;
填空题在关系运算中, 【5】 运算是在给定关系的某些域上进行的运算。
填空题阅读下面程序: #include <iostream.h> void main() int i,j,row=0,column=0,m; static int a[3][3]= 100,28,72,-30,2,-100; m=a[0][0]; for(i=0;i<3;i++) for(j=0;j<3;j++) if (a[i][j]<m) m=a[i][j]; row=i; column=j; cout<<m<<","<<row<<","<<column<<endl; 该程序的功能是______,其执行结果为______。
填空题下列程序的输出结果为: Ohject id=0 Object id=1 请将程序补充完整。 #include <iostream> using namespaee std; class Point public: Point(int xx=0,intyy=0)X=xx;Y=yy;countP++; ~Point( )countP--; int GetX( )return X; int GetY( )return Y; static void GetC( ) cout<<"Object id="<<<countP<<endl; private: int X,Y; static int countP; ; ______ //静态数据成员的初始化 int main( ) Point::GetC( ); Point A(4,5); A.GetC( ); return 0;
填空题在一个函数的定义或声明前加上关键字______时,该函数就声明为内联函数。
填空题若有定义:double a[3][5];那么数组a的最后一个元素是 【9】 。
填空题派生类中的成员不能直接访问基类中的{{U}} 【11】 {{/U}}成员。
填空题如果不能使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基数继承的成员,下列程序没有使用多态机制,其输出结果是______。
#include<iostream>
using namespaee std;
class Base{
public:
void print( ){tout<<"B";}
}
class Derived:publie Base{
public:
void print( ){tout<<"D";}
}
int main( ){
Derived*pd=new Derived( );
Base*pb=pd:
pb->print( );
pd->print( );
delete pd;
return 0;
}