#GESP0325. [GESP202506 三级]选择+判断

[GESP202506 三级]选择+判断

  1. 8 位二进制原码能表示的最小整数是:( )

{{ select(1) }}

  • -127
  • -128
  • -255
  • -256
  1. 反码表示中,零的表示形式有:

{{ select(2) }}

  • 1 种
  • 2 种
  • 8 种
  • 16 种
  1. 补码 1011\ 1011 对应的真值是( )

{{ select(3) }}

  • -69
  • -59
  • -68
  • -58
  1. 若 X 的 8 位补码为 0000\ 1010,则 X/2 的补码是( )。

{{ select(4) }}

  • 0000 01010000\ 0101
  • 1000 01011000\ 0101
  • 0000 01010000\ 01011000 01011000\ 0101
  • 算术右移后结果取决于符号位
  1. 二进制数 1101.101 对应的十进制数是( )

{{ select(5) }}

  • 13.625
  • 12.75
  • 11.875
  • 14.5
  1. 补码加法中,若符号位无进位而次高位有进位,则说明( )

{{ select(6) }}

  • 结果正确
  • 发生上溢
  • 发生下溢
  • 结果符号位错误
  1. 八进制数 35.6 对应的十进制数是( )

{{ select(7) }}

  • 29.75
  • 28.5
  • 27.625
  • 30.25
  1. 二进制数 1010 \mid 1100 的结果是( )

{{ select(8) }}

  • 1000
  • 1110
  • 1010
  • 1100
  1. 以下哪个位运算可以交换两个变量的值(无需临时变量)( )

{{ select(9) }}

  • a = a ^ b; b = a ^ b; a = a ^ b;
  • a = a & b; b = a | b; a = a & b;
  • a = a | b; b = a ^ b; a = a ^ b;
  • a = ~a; b = ~b; a = ~a;
  1. 如何正确定义一个长度为 5 的整型数组( )

{{ select(10) }}

  • int array = new int[5];
  • array int[5];
  • int[] array = {1,2,3,4,5};
  • int array[5];
  1. 以下程序使用枚举法(穷举法)求解满足条件的三位数,横线处应该填入的是( )
#include <iostream>
using namespace std;

int main() {
 int count = 0;
 for (int i = 100; i <= 999; i++) {
 int a = i / 100;
 // 横线处
 int c = i % 10;
 if (a * a + b * b == c * c) {
 count++;
 }
 }
 cout << count << endl;
 return 0;
}

{{ select(11) }}

  • int b = (i / 10) / 10;
  • int b = (i / 10) % 10;
  • int b = (i % 10) / 10;
  • int b = (i % 10) % 10;
  1. 以下程序模拟了一个简单的小球反弹过程,横线处应该填入的是( )
#include <iostream>
using namespace std;

int main() {
 int height = 10;
 int distance = 0;
 for (int i = 1; i <= 5; i++) { // 模拟5次落地
 ________________
 height /= 2;
 distance += height;
 }
 cout << distance << endl;
 return 0;
}

{{ select(12) }}

  • distance += height/2;
  • distance += height;
  • distance += height*2;
  • distance += height+1;
  1. C++ 代码 string s = "GESP考试";,s 占据的字节数是( )

{{ select(13) }}

  • 10
  • 8
  • 8 或 10
  • 取决于计算机采用什么编码
  1. C++ 语句 string s="Gesp Test"; 执行 s.rfind("e") 以后,输出的是( )

{{ select(14) }}

  • 1
  • 2
  • 6
  • 3
  1. 字符串 "Gesp考试",字符数是( )

{{ select(15) }}

  • 10
  • 8
  • 6
  • 字符数多少取决于编码
  1. C++ 中 string== 运算符比较的是字符串的内存地址,而非内容。

{{ select(16) }}

  • T
  • F
  1. stringsubstr(1, 3) 返回从下标 1 开始的 3 个字符的子串。

{{ select(17) }}

  • T
  • F
  1. x 是浮点数,(x >> 1) 等价于 x / 2

{{ select(18) }}

  • T
  • F
  1. string("hello") == "hello" 的比较结果为 true

{{ select(19) }}

  • T
  • F
  1. sort 可以直接用于排序 set 中的元素。

{{ select(20) }}

  • T
  • F
  1. (x & 1) == 0 可以判断整数 x 是否为偶数。

{{ select(21) }}

  • T
  • F
  1. stringsubstr(2, 10) 在字符串长度不足时会抛出异常。

{{ select(22) }}

  • T
  • F
  1. 在数学纸面计算中,pow(2, 3) 的计算结果一定是 8,但是在 C++ 中,如果遇到数据类型是浮点数,那就不一定正确。

{{ select(23) }}

  • T
  • F
  1. 在 C++ 中,枚举的底层类型可以是非整型(如 floatdouble)。

{{ select(24) }}

  • T
  • F
  1. 函数声明 double f(); 返回 int 时,会自动转换为 double

{{ select(25) }}

  • T
  • F