计算机二级

3773考试网计算机等级考试计算机二级正文

2013计算机二级考试C++模拟试题十九及答案4

来源:2exam.com 2013-9-30 9:52:58

 28.表示在输出时显示小数位,和在文件输入时判断文件尾的函数分别是
  A)showbase()和eof() 
  B)showpoint()和eof()
  C)showpoint()和bad() 
  D)showpoint()和good()
  【参考答案】B
  29.下面程序段的运行结果是
  void main()
  { int t, a, b, c;
  a=1;b=2;c=2;
  while(a 
  { t=a;a=b;b=t;c--;}
  cout << a << "," << b << "," << c; }
  A)1,2,0 
  B)2,1,0 
  C)1,2,1 
  D)2,1,1
  【参考答案】A
   30.下列程序中画线处应填入的语句是
  class Base
  { public:
  void fun(){cout<<"Base of fun"< 
  class Derived:public Base
  { void fun()
  { //显示基类的成员函数fun
  cout<<"Derived of fun"< 
  A)fun(); 
  B)Base.fun(); 
  C)Base::fun(); 
  D)Base->fun();
  【参考答案】C
  31.若定义int k=7,x=12;,则能使值为3的表达式是
  A)x%=(k%=5) 
  B)x%=(k-k%5) 
  C)x%=k-k%5 
  D)(x%=k)-(k%=5)
  【参考答案】D
  32.在位运算中,操作数每右移一位,其结果相当于
  A)操作数乘以2 
  B)操作数除以2 
  C)操作数乘以4 
  D)操作数除以4
  【参考答案】B
  33.有以下结构体说明和变量的定义,且指针p指向变量a,指针q指向变量b。则不能把结点b连接到结点a之后的语句是
  struct node
  { char data;
  struct node *next;
  } a,b,*p=&a,*q=&b;
  A)a.next=q; 
  B)p.next=&b;
  C)p->next=&b; 
  D)(*p).next=q;
  【参考答案】B
  34.一个类的友元函数能够访问该类的
  A)私有成员 
  B)保护成员 
  C)公有成员 
  D)所有成员
  【参考答案】D
  35.下面程序的输出结果是
  #include
   #include
  void main() 
  { char p1[10],p2[10];
  strcpy(p1,"abc");
  strcpy(p2,"ABC");
  char str[50]= "xyz";
  strcpy(str+2,strcat(p1,p2));
  cout << str; }
  A)xyzabcABC 
  B)zabcABC 
  C)xyabcABC 
  D)yzabcABC
  【参考答案】C

触屏版 电脑版
3773考试网 琼ICP备12003406号-1