c++语言题库,C++题库完整版.doc
C题库完整版程序控制结构本题序号:17有如下程序:# include # include void main( ){int s[ ]={123, 234};cout<for(int i=0; i<2; i++){cout<}}运行时的输出结果是( )。A123234B***123234C***123***234D***123234***参考答案B有如下程序:# include u
C题库完整版
程序控制结构
本题序号:17
有如下程序:
# include
# include
void main( )
{
int s[ ]={123, 234};
cout<
for(int i=0; i<2; i++)
{
cout<
}
}
运行时的输出结果是( )。A
123
234B
***123
234C
***123
***234D
***123
234***参考答案B
有如下程序:
# include
using namespace std;
class Publication{ //出版物类
char name[30];
public:
Publication(char *name="未知名称"){
strcpy(this->name,name);
}
const char * getName()const{ return name; }
virtual const char * getType()const{ return "未知类型";}
};
class Book: public Publication{ //书类
public:
Book(char *name): Publication(name){}
virtual const char * getType()const{ return "书";}
};
void showPublication( Publication &p){
cout<
}
int main(){
Book book("精彩人生");
showPublication(book);
return 0;
}
运行时的输出结果是 A?未知类型:未知名称 B?未知类型:精彩人生 C?书:未知名称 D?书:精彩人生 参考答案 D
本题序号:24
有如下程序:
# include
using namespace std;
class A {
public:
A(int i) : r1(i) {}
void print() {cout<
void print() const {cout<
private:
int r1;
};
int main(){
A a1(2); const A a2(4);
a1.print(); a2.print();
return 0;
}运行时的输出结果是 A?运行时出错 B?E2-C16- C?C4-C16- D?E2-E4- 参考答案 B
本题序号:31
有如下程序段:
??? int i=1;
??? while(1)
? ?{? i++;
????? if (i==10) break;
????? if (i%2==0)? cout<
??? }
执行这个程序段输出字符*的个数是(????? )。 A?10 B?3 C?4 D?5 参考答案 C
本题序号:80 有如下程序: int x=3; do { ?? x-=2; ?? cout<
本题序号:89
有如下语句序列: int k=0; do { ???k+=5; ???cout<0) ???cout <
本题序号:105
已知语句:
while(!x)
其中表达式!x等价于__________。 A?x=1 B?x!=0 C?x==0? D?x!=1 参考答案 C
本题序号:107 C++语言的跳转语句中,对于break和continue说法正确的是__________。 A?break语句只应用于循环体中 B?continue语句只应用于循环体中 C?break是无条件跳转语句,continue不是 D?break和continue的跳转范围不够明确,容易产生问题 参考答案 B
本题序号:149
在下面的循环语句中循环体执行的次数为 ????????????????。
for(int i=0;i<
更多推荐
所有评论(0)