We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bin_insertion_sort.rs 17行开始的以下代码段中
// 二分法找到 temp 的位置 while left <= right { mid = (left + right) >> 1; if temp < nums[mid] { right = mid - 1; } else { left = mid + 1; } }
mid 为 usize 类型,若待排序数组为 [2,3,1,4] ,则会出现 0 usize - 1 的情况,造成程序 panic ,加上一段对 mid 为 0 的处理就好,代码如下
mid
usize
[2,3,1,4]
0 usize - 1
panic
while left <= right { mid = (left + right) >> 1; if temp < nums[mid] { if mid == 0 {break;} right = mid - 1; } else { left = mid + 1; } }
The text was updated successfully, but these errors were encountered:
已修复,多谢!
Sorry, something went wrong.
No branches or pull requests
bin_insertion_sort.rs 17行开始的以下代码段中
mid
为usize
类型,若待排序数组为[2,3,1,4]
,则会出现0 usize - 1
的情况,造成程序panic
,加上一段对mid
为 0 的处理就好,代码如下The text was updated successfully, but these errors were encountered: