#gesp3s25. 2025GESP三级字符串
2025GESP三级字符串
2025GESP三级字符串
2503真题
1.(2503-13)下面程序最后能够得到 HelloC++ 的是()?
int main() {
string str = "HelloWorld";
___________________
cout << str;
return 0;
}
{{ select(1) }}
- str.replace(0, 5, "C++");
- str.replace(5, 5, "C++");
- str.replace(1, 5, "C++");
- str.replace(4, 5, "C++");
2.(2503-14)想要得到字符串 world ,下面程序横线处应该填入的是()?
#include <iostream>
#include <string>
using namespace std;
int main() {
string str = "HelloC++";
_________________
_________________
return 0;
}
{{ select(2) }}
-
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);
2506真题
1.(2506-13)C++代码 string s = "GESP考试"; ,s占据的字节数是()? {{ select(3) }}
- 10
- 8
- 8或10
- 取决于计算机采用什么编码
2.(2506-14)C++语句 string s="Gesp Test"; 执行s.rfind("e")以后,输出的是()? {{ select(4) }}
- 1
- 2
- 6
- 3
3.(2506-15)字符串"Gesp考试",字符数是()? {{ select(5) }}
- 10
- 8
- 6
- 字符数多少取决于编码
2509真题
1.(2509-15)以下关于C++中 string 类和字符数组( char[] )的说法,错误的是()? {{ select(6) }}
- string 对象可以使用 = 进行赋值,而字符数组需要使用 strcpy 。
- string 对象的长度可以使用 length() 成员函数获取,而字符数组需要使用 strlen() 函数。
- string 对象在内存中是动态分配空间的,因此可以自动处理字符串长度的变化。
- string 对象和字符数组都可以使用 == 运算符来直接比较两个字符串的内容是否相同。
2512真题
1.(2512-15)如果字符串 s 的值是 GESP ,以下代码 s 的最后结果是()?
for (int i = 0; i < s.length(); i++) {
s[i] = toupper(s[i] + i);
}
{{ select(7) }}
- GESP
- HFTR
- hesp
- GFUS