参考答案和解析
正确答案:C
更多“( 14 )执行以下程序后输出的是Private Sub Command1_Click()Ch$= ” AABCDEFGH ”Print Mid(Righ(c ”相关问题
  • 第1题:

    执行下面的程序,单击命令按钮后,窗体中的输出结果是 ______。 Private Sub Cotomand1_Click() Ch$="Welcome Home!" a=Len(ch$) For i= 1 To a b$ = Mid(ch$, i 1) If b$ = "m" Then m = m + 1 Next 1 Print m End Sub

    A.2

    B.3

    C.1

    D.0


    正确答案:A
    解析:题中程序的功能是统计字母m在字符串“WelcomeHome!”中出现的次数。程序中有两个字符串函数,Len()和Mid()。Len()函数的作用为计算字符串中字符的个数,而Mid()函数的作用为取子串。题中依次选取字符串中的字母,与字符“m”进行比较,所以答案选A。

  • 第2题:

    执行以下程序后输出的是。 Private Sub Commandl_Click ch$ = "ABCDEFGH": Print Mid(Right(ch$, 6), Len(Left(ch$, 4)), 2) End Sub A.CDEFGH B.ABCD C.FG D.AB


    正确答案:D

  • 第3题:

    在执行以下程序时,如果从键盘上输入:ABCdef<回车>,则输出为______。 main() { char ch; while((ch

    在执行以下程序时,如果从键盘上输入:ABCdef<回车>,则输出为______。 main() { char ch; while((ch=getchar())!='\n') { if(ch>='A' && ch<='Z') ch=ch+32; else if(ch>='a'&&ch<='2')ch=ch-32; printf("%c",ch); } printf("\n"); }

    A.ABCdef

    B.abcDEF

    C.abc

    D.DEF


    正确答案:B

  • 第4题:

    有如下程序: include using namespace std; class TestClass { private: int x,y; pu

    有如下程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"print1"<<end1; } void print()const { cout<<"print2"<<end1; } }; int main() { const TestClass a(1,2); a.print(); return 0; } 该程序运行后的输出结果是( )。

    A.print1

    B.print2

    C.print1 print2

    D.程序编译时出错


    正确答案:B
    解析:由主函数main入手,定义TestClass型的常对象a,然后调用对象a中的成员函数print()。因为在C++中,如果一个对象被声明为常对象,则不能调用该对象中的非const型的成员函数。所以,这里调用的是对象中的const型成员函数“void print()const”,输出为print2。

  • 第5题:

    若有以下程序: include usingnamespace std; class Sample { private: const int n;

    若有以下程序:

    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;

    }

    上述程序运行后的输出结果是【 】。


    正确答案:n=10
    n=10 解析:本题考核常成员数据的应用。类Sample中,定义了一个常数据成员n,所以构造函数只能通过初始化列表来初始化它。