单击命令按钮时,下列程序的执行结果是
Private Sub Command1_Click()
BT 4
End Sub
Private Sub BT(x As Integer)
x=x*2 + 1
If x < 6 Then
Call BT(x)
End If
x=x 2
Print x;
End Sub
A.15
B.16
C.17
D.18
第1题:
若有以下程序:
include <iostream>
using namespace std;
class Sample
{
private:
const int n;
public:
Sample(int i) :n(i) {)
void print()
{
cout<<"n="<<n<<end1;
}
};
int main()
{
sample a(10);
a.print();
return 0;
}
上述程序运行后的输出结果是【 】。
第2题:
单击命令按钮时,下列程序的执行结果是 Private Sub Command1_Click() BT4 End Sub Private Sub BT(x As Integer) x=x * 2 + 1 If x<6 Then Call BT(x) End If x=X * 2 Print x; End Sub
A.15
B.16
C.17
D.18
第3题:
单击命令按钮时,下列程序的执行结果是 Private Sub Commandl_Click( ) BT 4 End Sub PriVate Sub BT(x As Integer) X=X * 2 + 1 If x <6 Then Call BT(x) End If X=x * 2 Print x; End Sub
A.15
B.16
C.17
D.18
第4题:
若有以下程序: #include <iostream> using namespace std; class myClass { private: int var; public: myClass(int i) { var=i; } void add() { s+=var; } static int s; void display() { cout<<s<<end1; } }; int myClass::s=0; int main ( ) { myClass a(1),b(2),c(3); a.add(); b.add(); c.dislay(); return O; } 程序执行后的输出结果是( )。
A.1
B.4
C.3
D.7
第5题:
若有以下程序: #include <iostream> using namespace std; class Base { private: int a,b; public: Base(int x, int y) { a=x; b=y; } void disp () { cout<<a<<" "<<b<<end1; } }; class Derived : public Base { private: int c; int d; public: Derived(int x,int y, int z,int m) :Base(x,y) { c=z; d=m; } void disp () { cout<<c<<" "<<d<<end1; } }; int main() { Base b(5,5),*pb; Derived obj(1,2,3,4); pb=&obj; pb->disp(); return 0; } 执行程序后的输出结果是( )。
A.1,2
B.3,4
C.2,3
D.5,5