第21059题 单选题
检查字符串括号是否匹配的C++代码中第17行横线处应填写的内容是?
1 bool isBalanced(string s) {
2  stack<char> st;
3  for (char c : s) {
4   if (c == '(' || c == '[' || c == '{') {
5    st.push(c);
6   } else {
7    if (st.empty()) return false; // 无左括号匹配
8    char top = st.top();
9    st.pop();
10    if ((c == ')' && top != '(') ||
11     (c == ']' && top != '[') ||
12     (c == '}' && top != '{')) {
13     return false;
14    }
15   }
16  }
17  return ________________; //在此处填入代码
18 }
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析