#382. GESP模拟赛1

GESP模拟赛1

1. 8 位二进制补码 11010100 对应的十进制真值是( )。
{{ select(1) }}

  • -44
  • -83
  • 212
  • -84

2. 一个 32 位无符号整数int类型能表示的最大值,最接近下面哪个选项( )。
{{ select(2) }}

  • 41094*10^9
  • 310103*10^{10}
  • 21092*10^9
  • 210102*10^{10}

3. 下面C++代码执行,其输出是( )。

    #include <iostream>
    using namespace std;
    int main() {
        int a = 0b1011;
        int b = 0b1101;
        cout << (a & b);
        return 0;
    }

{{ select(3) }}

  • 0b1001
  • 9
  • 0b1111
  • 15

4. C++ 中,以下哪种方式定义的数组可以动态调整大小( )

{{ select(4) }}

  • int arr[10];
  • int* arr = new int[10];
  • vector<int> arr(10);
  • int arr[] = {1,2,3};

5. 以下关于指针的操作,正确的是( )。

{{ select(5) }}

  • int a = 5; int* p = a;
  • int a = 5; int* p = &a; *p = 10;
  • int a = 5; int* p = nullptr; *p = &a;
  • int a = 5; int* p = &a; p = 20;

6. 十进制数 76.875 对应的二进制是( )

{{ select(6) }}

  • 1001100.111
  • 1001100.110
  • 1001010.111
  • 1001011.101

7. 下面C++代码执行后输出是( )。

    #include <iostream>
    #include <string>
    using namespace std;
    int main() {
        string s = "GESP2025";
        cout << s.substr(4, 4);
        return 0;
    }

{{ select(7) }}

  • 2025
  • ESP2
  • GESP
  • 2025\0

8. 以下关于函数参数传递的说法,错误的是( )

{{ select(8) }}

  • 值传递会拷贝实参的值,修改形参不影响实参
  • 引用传递直接操作实参,无需拷贝
  • 指针传递可以实现多值返回
  • 引用传递的参数必须在函数调用时初始化

9. 要实现 “将数组元素按升序排序”,以下代码横线处应填入( )。

    #include <iostream>
    using namespace std;
    int main() {
        int arr[] = {5,3,8,1,2};
        int n = 5;
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < n-1-i; j++) {
                if (__________) {
                    swap(arr[j], arr[j+1]);
                }
            }
        }
        return 0;
    }

{{ select(9) }}

  • arr[j] < arr[j+1]
  • arr[j] > arr[j+1]
  • arr[j] == arr[j+1]
  • arr[j] != arr[j+1]

10. 以下结构体定义和初始化正确的是( )。

{{ select(10) }}

  • struct Point { int x,y; }; Point p(1,2);
  • struct Point { int x,y; }; Point p = {1,2};
  • struct Point { int x,y; }; Point* p = {1,2};
  • struct Point { int x,y; }; Point p; p = (1,2);

11. 下列代码运行结果是()。

    void increaseA(int x) {
        x++;
    }
    void increaseB(int* p) {
        (*p)++;
    }
    int main() {
        int a = 5;
        increaseA(a);
        cout << a << " ";
        increaseB(&a);
        cout << a;
    }

{{ select(11) }}

  • 6 7
  • 6 6
  • 5 6
  • 5 5

12. 以下关于 string 类和字符数组的说法,正确的是( )
{{ select(12) }}

  • string 类的字符串不能使用下标访问
  • 字符数组的长度可以通过 length () 方法获取
  • string 类可以直接用 "+" 进行字符串拼接
  • 字符数组可以直接用 "=" 进行赋值

13. 二维数组 int arr [3][4] = {{1},{2,3},{4,5,6}}; 中,*(*(arr+2)+1) 的值是( )

{{ select(13) }}

  • 5
  • 6
  • 3
  • 2

以下代码用于查找数组中的最小值,横线处应填入( )

    #include <iostream>
    using namespace std;
    int findMin(int arr[], int size) {
        int minVal = __________;
        for (int i = 1; i < size; i++) {
            if (arr[i] < minVal) {
                minVal = arr[i];
            }
        }
        return minVal;
    }

{{ select(14) }}

  • 0
  • arr[0]
  • arr[size-1]
  • INT_MAX

15. 关于排序算法的稳定性,以下说法错误的是( )
{{ select(15) }}

  • 稳定的排序算法不改变相等元素的相对位置
  • 冒泡排序是稳定的排序算法
  • 选择排序是稳定的排序算法
  • 插入排序是稳定的排序算法

16. 8 位有符号整数的补码 11111111 对应的十进制真值是 - 1( )
{{ select(16) }}

  • 正确
  • 错误

17. C++ 中,string s = "abc"; 执行 s.substr(1, 5) 会抛出数组越界异常( )
{{ select(17) }}

  • 正确
  • 错误

18. 表达式 (x & 1) == 1 可以准确判断整数 x 是否为奇数,无论 x 是正数还是负数( )
{{ select(18) }}

  • 正确
  • 错误

19. 结构体嵌套定义时,内部结构体必须在外部结构体使用前完成声明( )
{{ select(19) }}

  • 正确
  • 错误

20. C++ 中,const int a = 5; 定义的常量 a,其值在程序运行过程中可以通过指针间接修改( )
{{ select(20) }}

  • 正确
  • 错误

21. 递推算法的核心是通过已知初始值和递推关系,逐步推导更大规模问题的解,其时间复杂度一定低于递归算法( )
{{ select(21) }}

  • 正确
  • 错误

22. 选择排序是不稳定排序,而冒泡排序是稳定排序,两者最坏情况下的时间复杂度均为 O (n²)( )
{{ select(22) }}

  • 正确
  • 错误

23. C++ 中,全局变量未显式初始化时会被自动初始化为 0,而局部变量未初始化时值为随机数( )
{{ select(23) }}

  • 正确
  • 错误

24. 函数参数使用引用传递时,形参的修改会直接影响实参,但引用本身不能重新指向其他变量( )
{{ select(24) }}

  • 正确
  • 错误

25. 异常处理中,try 块中抛出的异常如果没有对应的 catch 块捕获,程序会直接编译失败( )
{{ select(25) }}

  • 正确
  • 错误