#GESP2024033K. GESP-C++ 三级客观题202403K

GESP-C++ 三级客观题202403K

一、单选题(每题 22 分,共 3030 分)

11、整数-5的16位补码表示是( )。​​

{{ select(1) }}

  • 1005
  • 1006
  • FFFA
  • FFFB

22、如果16位短整数 -2 的二进制是"FFFE",则短整数 -4 的十六进制是( )。

{{ select(2) }}

  • FF04
  • FFFA
  • FFFC
  • FFFH

33、下面C++代码执行后的输出是( )。

int main()
{
    cout << (3|16) << endl;
    cout << endl;
    return 0;
}

{{ select(3) }}

  • 3
  • 16
  • 19
  • 48

44、定义整数 int x=-5 ,则执行C++代码 cout << (x == (x<<1>>1)) 输出是( )。

{{ select(4) }}

  • 0
  • 1
  • -5
  • 5

55、已知字符 '0' 的ASCII编码的十进制表示为48,则执行下面C++代码后,输出是( )。

int main()
{
    string s="316";
    int n=s.length();
    int x=0;
    for(int i = 0; i < n; i++)
        x += s[i];
    cout << x << endl;
    cout << endl;
    return 0;
}

{{ select(5) }}

  • 10
  • 58
  • 154
  • 316

66、下面C++代码执行后数组中大于0的数的特征是( )。

int main()
{
    int a[20],i;
    for(i = 0; i < 20; i++)
        a[i] = i+1;
    for(int i = 0; i < 20; i++)
        if((a[i]%2)&&(a[i]%3))
            a[i] = 0;
    for(i = 0; i < 20; i++)
        if(a[i])
            cout << a[i] << " ";
    cout << endl;
    return 0;
}

{{ select(6) }}

  • 2的倍数
  • 3的倍数
  • 能被2或3整除的数
  • 能被2和3同时整除的数

77、执行下面C++代码后输出的第一个数是( )。

int main()
{
    int a[20],i;
    for(i = 0; i < 20; i++)
        a[i] = i+1;
  
    for( ; i > 0; i--)
        cout << a[i-1] << " ";
  
    cout << endl;
    return 0;
}

{{ select(7) }}

  • 20
  • 19
  • 1
  • 不确定

88、在下列代码的横线处填写( ),可以使得输出是 GESP IS INTERESTING 。

int main()
{
    string str="gEsP is Interesting";
    int x = str.length();
  
    for(int i = 0; i < x; i++)
        if ((str[i]>='a') && (str[i]<='z'))
            ________________________;
    cout << str << endl;
  
    cout << endl;
    return 0;
}

{{ select(8) }}

  • str[i]+='a'-'A'
  • str[i]+=20
  • str[i]+='A'-'a'
  • 无法实现

99、假设英文句子由若干词构成。下面C++代码统计输出的词数是( )。

int main()
{
    string str="gEsP is Interesting !";
    int x = str.length();
    int nwords = 0;
  
    for(int i = 0; i < x; i++)
        if (str[i]==' '){
            nwords++;
            while(str[++i]==' ') ;
        }
    cout << nwords << endl;
  
    cout << endl;
    return 0;
}

{{ select(9) }}

  • 1
  • 2
  • 3
  • 4

1010、C++的字符变量的码值是整数,下面字面量形式的字符码值最大的是( )。

{{ select(10) }}

  • 100
  • 075
  • 0x70
  • 0x60

1111、下面C++程序执行的结果是( )。

int main()
{
    int a[20],i;
    int cnt=0;
    for(i = 0; i < 20; i++)
        a[i] = i+1;
  
    for( ; i > 1; i--)
        if((a[i-1]+a[i-2])%3)
            cnt++;
    cout << cnt << endl;
  
    cout << endl;
    return 0;
}

{{ select(11) }}

  • 5
  • 6
  • 10
  • 12

1212、定义字符数组 char str[20] = {'G', 'E', 'S', 'P'}; ,则 str 的字符串长度为( )。

{{ select(12) }}

  • 4
  • 5
  • 19
  • 20

1313、定义整型变量 int a=3, b=16 ,则 a|b 的值和 a+b 的关系是( )。

{{ select(13) }}

  • 大于
  • 等于
  • 小于
  • 等于或小于

1414、小杨的父母最近刚刚给他买了一块华为手表,他说手表上跑的是鸿蒙,这个鸿蒙是( )。

{{ select(14) }}

  • 小程序
  • 计时器
  • 操作系统
  • 神话人物

1515、中国计算机学会(CCF)在2024年1月27日的颁奖典礼上颁布了王选奖,王选先生的重大贡献是( )。

{{ select(15) }}

  • 制造自动驾驶汽车
  • 创立培训学校
  • 发明汉字激光照排系统
  • 成立方正公司

二、判断题(每题 22 分,共 2020 分)

1616、任意整数 a 的二进制反码与补码都有1位不同。 ( )

{{ select(16) }}

  • 正确
  • 错误

1717、对整型变量 int a = 3 ,执行C++代码 a<<2 将把2输出到 a 中。( )

int main()
{
    int i,sum=0;
    for(int i = 1; i <= 100 ; i++)
        sum += i;
    cout << sum << endl;
  
    cout << endl;
    return 0;
}

{{ select(17) }}

  • 正确
  • 错误

1818、下面C++代码可以计算1到100的累加和,采用的是穷举法。

{{ select(18) }}

  • 正确
  • 错误

1919、一个 int 类型变量 a ,执行操作 (a<<2>>2) 后的值一定是 a 。( )

{{ select(19) }}

  • 正确
  • 错误

2020、在C++语言中, (010<<1) 执行结果是 100 。( )

{{ select(20) }}

  • 正确
  • 错误

2121、执行下面C++代码后将输出 2 。( )

int main()
{
    string str="gEsP is Interesting";
    int x = str.find("s");
  
    cout << x << endl;
  
    cout << endl;
    return 0;
}

{{ select(21) }}

  • 正确
  • 错误

2222、在C++语言中,字符数组被定义时,它的大小可以调整。( )

{{ select(22) }}

  • 正确
  • 错误

2323、对定义的数组 int a[7]={2,0,2,4,3,1,6} ,可以用简单循环就找到其中最小的整数。( )

{{ select(23) }}

  • 正确
  • 错误

2424、小杨今年春节回奶奶家了,奶奶家的数字电视要设置ip地址并接入到WIFI盒子才能收看节目,那这个WIFI盒子具有路由器的功能。( )

{{ select(24) }}

  • 正确
  • 错误

2525、任何一个 for 循环都可以转化为等价的 while 循环( )。

{{ select(25) }}

  • 正确
  • 错误