#1862. 珅泽教育CSP-J第一轮模拟考第十套 第 31 题
珅泽教育CSP-J第一轮模拟考第十套 第 31 题
第三题
using std::string;
string post(const string& pre, const string& in)
{
if (pre == "") return "";
char root = pre[0];
int i = 0;
while (root != in[i]) ++i;
string left_in = in.substr(0, i);
string right_in = in.substr(i+1);
string left_pre = pre.substr(1, i);
string right_pre = pre.substr(i+1);
string left_post = post(left_pre, left_in);
string right_post = post(right_pre, right_in);
return left_post + right_post + root;
}
判断题
当参数 pre 中出现参数 in 所没有的字符时,程序会发生运行时错误( )。
{{ select(1) }}
- 正确
- 错误