#1863. 珅泽教育CSP-J第一轮模拟考第十套 第 32 题
珅泽教育CSP-J第一轮模拟考第十套 第 32 题
第三题
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;
}
判断题
当程序正常运行时,post 函数返回的字符串与参数 pre 等长( )。
{{ select(1) }}
- 正确
- 错误