本栏目下题库来源于互联网,轻速云承诺对于用户导入平台的题库是严格保密的,不会在此呈现!
轻速云给您提供更好的在线考试系统服务!
2013年9月全国计算机等级《二级C++》上机临考冲刺试卷(1)
1、【 单选题 】
如果表达式-x/y中的“--”和“/”是作为友元函数重载的运算符,采用运算符函数调用格式,该表达式还可表示为(  )。 [1分]
、 operator/(x.operator--(),y);
、 operator/(operator--(x),y);
、 X.operator--().operator/(y);
、 y.operator/(operator--(x));
答案:
2、【 单选题 】
有下列程序:
#include
intfun(inta.intb)
{if(b==0)relurna;
elsereturn(fun(--a,--b));
}
voidmain(  )
{printf("%d\n",fun(4,2));}
程序的运行结果是(  )。 [1分]
、 1
、 2
、 3
、 4
答案:
3、【 单选题 】
有下列程序:
#includeintf(intx,inty)
{return((y-x)*x);}
voidmain(  )
{inta=3,b=4,c=5,d;
d=f(f(a,b),f(a,c));
printf("%d\n",d);
}
程序运行后的输出结果是(  )。 [1分]
、 10
、 9
、 8
、 7
答案:
4、【 单选题 】
有如下程序:
#include
Usingnamespacestd;
classBase{
public:
Base(intx=O):valB(x){cout<<valb;)
~Base(  ){cout<<valb;)
Private:
intvalB:
};
classDerived:publicBase{
public:
Derived(intX=0,inty=0):Base(x),valD(y)(cout<<vald;)
~Derived(  ){cout<<vald;)
private:
intvalD;
};
intmain(  ){
Derivedobj12(2,3);
return0;
}
运行时的输出结果是(  )。 [1分]
、 2332
、 2323
、 3232
、 3223
答案:
5、【 单选题 】
执行下列语句序列:
inti=0;while(i<25)i+=3;cout<
输出结果是(  )。 [1分]
、 24
、 25
、 27
、 28
答案:
6、【 单选题 】
有下列程序:
#include
#include"string.h"
voidfun(char*s[],intn)
{
char*t;inti,j
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(strlen(s[i]>strlen(s[j])){t=s[i];s[i]=s
[j];s[j]=t;}
}
voidmain(  )
{
char*ss[]=("bcc","bbcc","xy","aaaacc","aab—
cc"};
fun(ss,5);printf("%s,%s\n",ss[O],ss[4]);}
程序的运行结果是(  )。 [1分]
、 xy,aaaacc
、 aaaacc,xy
、 bcc,aabcc
、 aabcc,bcc
答案:
7、【 单选题 】
有如下程序:
#include
usingnamespacestd;
classAA{
intn;
public:
AA(intk):n(k){}
intget(){returnn;}
intget()const{returnn+1;}
};
intmain()
{
AAa(5);
constAAb(6);
cout<<a.get()<
return0;
}
执行后的输出结果是()。 [1分]
、 55
、 57
、 75
、 77
答案:
8、【 单选题 】
假定已建立以下链表结构,且指针P和q已指向如下图所示的结点:
   
则下列选项中可将q所指点从链表中删除并释放该结点的语句组是(  )。 [1分]
、 (*p).next=(*q).next;free(p);
、 p=q->next;flee(q);
、 p=q;free(q);
、 p->next=q->next;free(q);
答案:
9、【 单选题 】
下列关于函数的描述中,错误的是(  )。 [1分]
、 函数可以没有返回值
、 函数可以没有参数
、 函数可以是一个类的成员
、 函数不能被定义为模板
答案:
10、【 单选题 】
若是对类BigNumber中重载的类型转换运算符long进行声明,下列选项中正确的是(  )。 [1分]
、 operatorlong()const;
、 operatorlong(BigNumber);
、 10ngoperatorlong()const;
、 10ngoperatorlong(BigNumber);
答案:
11、【 单选题 】
用树型结构表示实体之间联系的模型是(  )。 [1分]
、 关系模型
、 网状模型
、 层次模型
、 以上三个都是
答案:
12、【 单选题 】
有如下两个类定义:
classXX{
private:
doublexl;
protected:
doublex2;
public:
doublex3;
};
claseYY:protectedXX{
private:
doubleyl;
protected:
doubley2;
public:
doubley3;
};
在类YY中保护成员变量的个数是(  )。 [1分]
、 1
、 2
、 3
、 4
答案:
13、【 单选题 】
如果进栈序列为e1、e2、e3、e4,则可能的出栈序列是(  )。 [1分]
、 e3、e1、e4、e2
、 e2、e4、e3、e1
、 e3、e4、e1、e2
、 任意顺序
答案:
14、【 单选题 】
当派生类从一个基类保护继承时,基类中的一些成员在派生类中成为保护成员,这些成员在基类中原有的访问属性是(  )。 [1分]
、 任何
、 公有或保护
、 保护或私有
、 私有
答案:
15、【 单选题 】
设有定义“intx=2;”,下列表达式中,值不为6的是(  )。 [1分]
、 X*=x+1
、 x++,2*x
、 x*=(1+x)
、 2*x,x+=2
答案:
16、【 单选题 】
在长度为n的有序线性表中进行二分查找,最坏情况下需要比较的次数是(  )。 [1分]
、 O(n)
、 O(n2)
、 O(log2n)
、 O(nlog2n)
答案:
17、【 单选题 】
有以下程序:
#include
usingnamespacestd;
classA
{private:
inta:
public:
A(inti)
{a=i;}
voiddisp()
{cout<<a<<",";));
classB
(private:
intb;
public:
B(intj)
{b=j;}
voiddisp()
{cout<<b<<",";}};
classC:publicB,publicA
{private:
intC;
public:
c(intk):A(k-2),B(k+2)
{c=k;
}
voiddisp()
{
a::disp();
B::disp();
COUt<<c<
}
};
intmain()
{
Cobj(10);
obj.disp();
return0;
}
程序执行后的输出结果是(  )。 [1分]
、 10,10,10
、 10,12,14
、 8,10,12
、 8,12,10
答案:
18、【 单选题 】
为了提高函数调用的实际运行速度,可以将较简单的函数定义为(  )。 [1分]
、 内联函数
、 重载函数
、 递归函数
、 函数模板
答案:
19、【 单选题 】
类MyClass的定义如下:
classMyClass
{
public:
MyClass(){value=0;}
SetVariable(inti){valtic=i;}
private:
intvalue;
};
MyClass*P,my;p=&my;
则对下列语句序列正确的描述是(  )。 [1分]
、 语句p=&my;是把对象my赋值给指针变量P
、 语句MyClass*P,my;会调用两次类MyClass的构造函数
、 对语句*P.SetVariable(5)的调用是正确的
、 语句P->SetVariable(5)与语句my.SetVariable(5)等价
答案:
20、【 单选题 】
若是对类BigNumber中重载的类型转换运算符long进行声明,下列选项中正确的是(  )。 [1分]
、 operatorlong(  )const;
、 operatorlong(BigNumber);
、 longoperatorlong(  )const;
、 longoperatorlong(BigNumber);
答案:
21、【 单选题 】
有如下程序:
#include
usingnamespacestd;
voidf1(int&X,int&y){intz=X;x=y;y=z}
voidf2(intX,inty){intz=x;x=y;y=z}
intmain(  ){
intx=10,y=26
f1(x,y);
f2(X,y);
cout<<y<
return0;
}
运行时的输出结果是(  )。 [1分]
、 10
、 16
、 26
、 36
答案:
22、【 单选题 】
下面程序的输出结果是(  )。#include
#include
voidmain()
{
charp1[10],p2[10];
strcpy(p1,"abc");
strcpy(p2,"ABC");
charstr[50]="xyz":
strcpy(str+2,strcat(p1,p2));
cout<
} [1分]
、 xyzabcABC
、 zabcABC
、 xyabcABC
、 yzabcABC
答案:
23、【 单选题 】
有下列程序:
#include
voidmain(  )
{FILE*f;
f=fopen("filea.txt","w");
fprintf(f,"abe");
fclose(f);
}
若文本文件filea.txt中原有内容hell0,则运行以上程序后,文件Iilea.txt中的内容为(  )。 [1分]
、 helloabe
、 abclo
、 abe
、 abchello
答案:
24、【 单选题 】
若执行下面的程序时,从键盘上输入5和2,则输出结果是(  )。
#include(iostream.h)
voidmain(  )
(inta,b,k;
cin>>a>>b;
k=a:
if(a<b)
k=a%b;
else
k=b%a:
cout((k<<endl;) [1分]
、 5
、 3
、 2
、 0
答案:
25、【 单选题 】
若已定义的函数有返回值,则以下关于该函数调用的叙述中错误的是(  )。 [1分]
、 函数调用可以作为独立的语句存在
、 函数调用可以无返回值
、 函数调用可以出现在表达式中
、 函数调用可以作为一个函数的形参
答案:
26、【 单选题 】
考虑以下的函数原型:
voldA(inta,intb=5,charZ='*');
下面的函数调用中,不正确的是(  )。 [1分]
、 A(7)
、 A(3,4)
、 A(16,'#')
、 A(0,2,'*')
答案:
27、【 单选题 】
下列叙述中正确的是(  )。 [1分]
、 顺序存储结构的存储空间一定是连续的,链式存储结构的存储空间不一定是连续的
、 顺序存储结构只针对线性结构,链式存储结构只针对非线性结构
、 顺序存储结构能存储有序表,链式存储结构不能存储有序表
、 链式存储结构比顺序存储结构节省存储空间
答案:
28、【 单选题 】
有如下程序:
#include
usingnamespacestd;
classTest(
public:
Test(  ){}
Test(constTest8Lt){cout<<1;}
};
Testfun(Test&u){Testt=U;returnt;}
intmain(  ){Testx,y;x=fun(y);return0;}
运行这个程序的输出结果是(  )。 [1分]
、 无输出
、 1
、 1l
、 111
答案:
29、【 单选题 】
与语句cout< [1分]
、 cout<<'\n';
、 cout<<'\12';
、 cout<<'\xA';
、 cout<<'\0';
答案:
30、【 单选题 】
软件(程序)调试的任务是(  )。 [1分]
、 诊断和改正程序中的错误
、 尽可能多地发现程序中的错误
、 发现并改正程序中的所有错误
、 确定程序中错误的性质
答案:
31、【 单选题 】
下列关于C++函数的说明中,正确的是(  )。 [1分]
、 内联函数就是定义在另一个函数体内部的函数
、 函数体的最后一条语句必须是return语句
、 标准C++要求在调用一个函数之前,必须先声明其原型
、 编译器会根据函数的返回值数型和参数表来区分函数的不同重载形式
答案:
32、【 单选题 】
程序中有语句:for(inti=0;i<5;i++)cout<<*(p+i)<<",";能够依次输出int型一维数组a的前5个元素。由此可知,变量P的定义及初始化语句是(  )。 [1分]
、 int*p=a;
、 intp=a;
、 "p=a;
、 p=a;
答案:
33、【 单选题 】
以下程序的输出结果是(  )。min(  )
{
inti=0,a=0;
while(i<20)
{
for(;;)
{
if((i%10)==0)break;
elsei--:
}
i+=11;a+=i;
}
cout<<a<
} [1分]
、 21
、 32
、 33
、 11
答案:
34、【 单选题 】
设有程序段:
intk=10。
while(k=O)k=k-1;
则下面描述中正确的是(  )。 [1分]
、 循环执行10次
、 无限循环
、 循环体语句一次也不执行
、 循环体语句执行一次
答案:
35、【 单选题 】
有如下类定义:
classXX{
intxdata;
public:
XX(intn=0):xdata(n){}
};
classYY:publicXX{
intydata;
public:
YY(intm=0,intn=O):XX(m),ydata(n){}
};
YY类的对象包含的数据成员的个数是(  )。 [1分]
、 1
、 2
、 3
、 4
答案:
36、【 单选题 】
下列关于类模板的描述中,错误的是(  )。 [1分]
、 类模板的成员函数都是模板函数
、 可以为类模板参数设置默认值
、 类模板描述了一组类
、 类模板中只允许有一个类型参数
答案:
37、【 单选题 】
有以下程序:
#include
usingnamespaeestd;
classMyClass
{
public:
MyClass(intn){number=n;}
//拷贝构造函数
MyClass(MyClass&other){number=other.number;}
~MyClass(){}
private:
intnumber;
};
MyClassfun(MyClassp)
{
MyClasstemp(p);
returntemp;
}
intmain()
{
MyCIassobj1(10),obj2(O);
MyClassobj3(obj1);
obj2=fun(obj3);
return0;
程序执行时,MyClass类的拷贝构造函数被调用的次数是(  )。 [1分]
、 5
、 4
、 3
、 2
答案:
38、【 单选题 】
下列工具中为需求分析常用工具的是(  )。 [1分]
、 PAD
、 PFD
、 N-S
、 DFD
答案:
39、【 单选题 】
下面的函数调用语句中func函数的实参个数是(  )。
func(f2(vl,v2),(v3,v4,v5),(v6,max(v7,v8))); [1分]
、 3
、 4
、 5
、 8
答案:
40、【 单选题 】
数据流程图(DFD)是(  )。 [1分]
、 软件概要设计的工具
、 软件详细设计的工具
、 结构化方法的需求分析工具
、 面向对象方法的需求分析工具
答案:
12 下一页 末页
共2页,共43个题库
共2页,共43个题库
轻速云给您提供更好的在线考试系统服务!
推荐
推荐题库
众多企事业单位的信赖之选
36万+企事业单位的共同选择
查看更多合作案例
众多企事业单位的信赖之选
开始使用轻速云组织培训考试
四步组织一场考试答题,一键搭建企业培训平台
免费使用 免费使用 预约演示
咨询热线
400-886-8169
周一到周日 8:00-22:00
©2025 轻速云 苏ICP备16049646号-1 轻速云科技提供专业的在线考试系统、在线培训系统
联系我们
客服热线客服热线:400-886-8169 | 周一至周日 8:00-22:00
©2025 轻速云 苏ICP备16049646号-1
轻速云科技提供专业的在线考试系统、在线培训系统
在线咨询 400-886-8169