#P1359. Day4 完善程序专项(12题)
Day4 完善程序专项(12题)
第 1 题
完善二分查找:填写右边界初值。
int l = 0, r = ____;
{{ input(1) }}
第 2 题
完善二分查找:填写闭区间循环条件。
while (____) { /* ... */ }
{{ input(2) }}
第 3 题
完善二分查找:中间值小于目标时填写更新语句。
if (a[mid] < x) ____;
{{ input(3) }}
第 4 题
完善二分查找:中间值大于目标时填写更新语句。
if (a[mid] > x) ____;
{{ input(4) }}
第 5 题
完善二分查找:找到目标时返回什么?
if (a[mid] == x) return ____;
{{ input(5) }}
第 6 题
完善括号匹配:遇到左括号时填写操作。
if (c == '(' || c == '[' || c == '{') ____;
{{ input(6) }}
第 7 题
完善括号匹配:取栈顶前应填写的空栈判断条件。
if (____) return false;
{{ input(7) }}
第 8 题
完善括号匹配:读取栈顶字符。
char t = ____;
{{ input(8) }}
第 9 题
完善括号匹配:读取栈顶后删除它。
char t = st.top();
____;
{{ input(9) }}
第 10 题
扫描结束后,括号全部匹配应返回什么表达式?
return ____;
{{ input(10) }}
第 11 题
完善队列程序:读取队首。
int y = ____;
{{ input(11) }}
第 12 题
完善队列程序:删除已读取的队首。
int y = q.front();
____;
{{ input(12) }}