0 #GESP142. GESP24年9月四级选择题

GESP24年9月四级选择题

  1. 在 C++ 中,( )正确定义了一个返回整数值并接受两个整数参数的函数。 {{ select(1) }}
  • int add(int a, int b) { return a + b; }
  • void add(int a, int b) { return a + b; }
  • int add(a, b) { return a + b; }
  • void add(int a, int b) { return a - b; }
  1. 在C++中,形参与实参的关系描述正确的是( )。 {{ select(2) }}
  • 形参在函数调用时指定,实参在函数定义时传递
  • 形参在函数定义时指定,实参在函数调用时传递
  • 形参和实参可以互换
  • 形参和实参必须是完全相同的类型,不能有任何差异。
  1. 运行以下代码,屏幕上将输出( )。 image {{ select(3) }}
  • 100 200 100 200
  • 100 200 100 300
  • 100 200 200 200
  • 100 200 200 300
  1. 运行下面代码,屏幕上输出是( )。 image {{ select(4) }}
  • 24
  • 9
  • 7
  • 不确定
  1. 运行下面代码片段的结果是( )。 image {{ select(5) }}
  • 将x赋值为24
  • 将y赋值为20
  • 将q指向x的地址
  • 将p指向y的地址
  1. 在 C++ 中,( )正确定义一个名为 student 的结构体,其中包含一个 name 字符数组和一个 age 整数? {{ select(6) }}
  • struct student { char name[20]; int age; };
  • student struct { char name[20]; int age; };
  • student struct { string name; int age; };
  • struct student { char[20] name; int age; };
  1. 在 C++ 中,( )正确声明了一个 3 行 4 列的二维数组。 {{ select(7) }}
  • int arr[3, 4];
  • int arr[3][4];
  • int arr[4][3];
  • int arr(3, 4);
  1. 一个二维数组定义为 int arr[3][4]; (假设一个int变量占4个字节),则 int arr[0] 占用( )个字节的内存。 {{ select(8) }}
  • 3
  • 4
  • 12
  • 16
  1. 下面代码采用递推算法来实现整数n的阶乘(n!=n * (n-1) * ... * 2 * 1),则横线上应填写( )。 image {{ select(9) }}
  • result *= i;
  • result += i;
  • result *= result;
  • result += result;
  1. 在排序算法中,稳定性指的是( )。

    {{ select(10) }}

  • 排序后数据不会丢失
  • 排序后相同元素的相对顺序保持不变
  • 排序后数据不会被修改
  • 排序后数据的时间复杂度不变
  1. 下面代码实现了冒泡排序函数,则横线上应填写( )。 image {{ select(11) }}
  • for (int j = 0; j < arr.size() - 1; j++)
  • for (int j = arr.size() - 1; j > 0; j--)
  • for (int j = 0; j < i; j++)
  • for (int j = i-1; j <=0; j--)
  1. 上一题算法的时间复杂度为( )。 {{ select(12) }}
  • O(n2^2)
  • O(2n^n)
  • O(1)
  • O(n)
  1. 下面代码实现了插入排序函数(升序),则横线上应填写( )。 image {{ select(13) }}
  • while (j >= 0 && nums[j] > base)
  • while (j > 0 && nums[j] > base)
  • while (j >= 0 && nums[j] < base)
  • while (j > 0 && nums[j] < base)
  1. 小杨用文件重定向实现在 log.txt 文件中输出日志,则下面横线上应填写( )。 image {{ select(14) }}
  • cout << "This output will go to the log file." << endl;
  • log_file << "This output will go to the log file." << endl;
  • cout >> "This output will go to the log file." >> endl;
  • log_file >> "This output will go to the log file." >> endl;
  1. 运行下面的代码,屏幕上将输出( )。 image {{ select(15) }}
  • division by zero error result: caught an exception:
  • result: caught an exception: division by zero error
  • caught an exception: division by zero error
  • division by zero error caught an exception: division by zero error