单项选择题

以下程序的输出结果是( )。
#include <iostream.h>
void main() int a=0,i;
for(i=1 ;i<5;i++)
switch(i)
case 0:
case 3: a+ =2;
case 1:
case 2: a+ =3;
default: a+ =5;
cout<<a<<end1;
return;

A.31
B.13
C.10
D.20
<上一题 目录 下一题>
热门 试题

单项选择题
有如下程序:#include <iostream>using namespace std;class Base private: void fun1() const cout << fun1 ; protected: void fun2() eonst cout << fun2 ; public: void tim3() const cout << fun3 ; ; class Derived: protected Base public: void fun4() const cout << fun4 ; ;int main()Derived obj;obj.fun1(); ①obj.fun2(); ②obj.fun3(); ③obj.fun4(); ④return 0;其中有语法错误的语句是( )。
A.①②③④
B.①②③
C.②③④
D.①④
单项选择题
若有以下程序:#include <iostream>using namespace std;class Aprivate: int x;public: int z; void setx(int i) x=i; int getx() return x;;class B: public Aprivate: int m;public: int p; void setvalue(int a, int b, int c) setx(a); z=b; m=c; void display() cout<<getx()<< , <<z<< , <<m<<end1;;int main() B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )。
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
相关试题
  • 下面是一个栈类的模板,其中push函数将元素...
  • 以下函数模板max()的功能是:返回数组a中...
  • 对于派生类的构造函数,在定义对象时构造函...
  • 下面是复数类complex的定义,其中重载的运...
  • 若有定义语句:int a=3,b=2,c=1;...