#GESP325031. GESP25年3月三级选择题
GESP25年3月三级选择题
一、提取选择题
- Base64 编码将每3字节的输入数据编码为 4 字节的输出数据。如果输入数据长度不是 3 的倍数,会用=号填充。在Base64编码中,如果输入字符串的长度为10字节,编码后的字符串长度是多少( ){{ select(1) }}
- 12 字节
- 13 字节
- 14 字节
- 16 字节
- UTF-8 编码规则如下: 1 字节:0xxxxxxx 2 字节:110xxxxx 10xxxxxx 3 字节:1110xxxx 10xxxxxx 10xxxxxx 4 字节:11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 以下哪个字节序列是合法的 UTF-8 编码( ){{ select(2) }}
- 0xC0 0x80
- 0xF0 0x90 0x80 0x80
- 0x80 0x80 0x80
- 0xFF 0xFE 0xFD
- 在 8 位二进制原码表示中,八进制数 -5 的二进制形式是什么( ){{ select(3) }}
- 10000101
- 11111010
- 11111011
- 00000101
- 十进制数 111.111 的二进制表示可以是下面的( ){{ select(4) }}
- 1101111.0001110001
- 1101110.1001110001
- 1101111.1001110001
- 1101111.0011110001
- 在C++中,补码的主要作用是(){{ select(5) }}
- 提高浮点数的精度
- 简化整数的加减法运算
- 增加整数的表示范围
- 优化内存分配
- 在C++中,一个8位有符号整数(使用补码表示)的范围是(){{ select(6) }}
- -128 到 127
- -127 到 128
- -256 到 255
- 0 到 255
- 在C++中,以下代码的输出是什么()
int a = -5;
unsigned int b = a;
cout << b;
{{ select(7) }}
- -5
- 5
- 4294967291
- 编译错误
- 下列程序的作用是()
int main() {
int decimal = 25;
cout << oct << decimal;
return 0;
}
{{ select(8) }}
- 将十进制数转换成八进制数
- 将八进制数转换成十进制数
- 将二进制数转换成八进制数
- 将八进制数转换成16进制数
- 下面程序是将十进制转十六进制,横线处应该填入的是()
#include <iostream>
using namespace std;
int main() {
int decimal = 255;
// 横线处代码
return 0;
}
{{ select(9) }}
- cout << oct << decimal;
- cout << decimal << decimal;
- cout << hex << decimal;
- 不能正确执行
- 以下代码的说法正确的是什么( )
#include <iostream>
using namespace std;
int main() {
int a = 0b1101;
int b = 0b1011;
cout << (a ^ b);
return 0;
}
{{ select(10) }}
- 进行的是整体异或运算
- 进行的是按位同或运算
- 进行的是按位与运算
- 进行的是按位异或运算
- 下面枚举法查找最大值索引程序中,横线处应该填写的是()
#include <iostream>
using namespace std;
int main() {
int arr[] = {3, 7, 2, 9, 5};
int maxIndex = 0;
for (int i = 1; i < 5; i++) {
// 横线处代码
maxIndex = i;
}
cout << maxIndex;
return 0;
}
{{ select(11) }}
- if (arr[maxIndex] > arr[i])
- if (arr[i]-1 > arr[maxIndex])
- if (arr[i]+1 > arr[maxIndex])
- if (arr[i] > arr[maxIndex])
- 以下代码的功能是将数组中的奇数和偶数分别放在数组的前半部分和后半部分,横线处应该填入的是()
#include <iostream>
using namespace std;
int main() {
int arr[] = {1, 2, 3, 4, 5};
int left = 0, right = 4;
while (left < right) {
while (arr[left] % 2 == 1 && left < right)
left++;
// 横线处代码
if (left < right) {
swap(arr[left], arr[right]);
}
}
for (int i = 0; i < 5; i++) {
cout << arr[i] << " ";
}
return 0;
}
{{ select(12) }}
- while (arr[left] % 2 == 0 && left < right) right--;
- while (arr[right] % 2 == 0 && left < right) left--;
- while (arr[right] % 2 != 0 && left < right) right--;
- while (arr[right] % 2 == 0 && left < right) right--;
- 下面程序最后能够得到“HelloC++”的是()
int main() {
string str = "HelloWorld";
// 横线处代码
cout << str;
return 0;
}
{{ select(13) }}
- str.replace(0, 5, "C++");
- str.replace(5, 5, "C++");
- str.replace(1, 5, "C++");
- str.replace(4, 5, "C++");
- 想要得到字符串“world”,下面程序横线处应该填入的是()
#include <iostream>
#include <string>
using namespace std;
int main() {
string str = "HelloC++";
// 横线处代码
return 0;
}
{{ select(14) }}
- str.insert(4, "World"); cout << str.substr(4, 4);
- cout << str.substr(5, 5);
- str.insert("World"); cout << str.substr(5, 5);
- str.insert(5, "World"); cout << str.substr(5, 5);
- 有 n 个正整数,假设一个正整数是美丽数字当且仅当该正整数是 9 的倍数但不是 8 的倍数。下面的程序是编写计算 n 个正整数中美丽数字的数量,横线处应该填入的是()
for (int i = 1; i <= n; i++) {
cin >> a;
// 横线处代码
cnt++;
}
{{ select(15) }}
- if (a % 9 != 0 && a % 8 != 0)
- if (a % 9 == 0 & a % 8 == 0)
- if (a % 9 == 0 && a % 8 != 0)
- if (a % 9 == 0 & a % 8 != 0)