Commit a655245b by BellCodeEditor

save project

parent 6f7c42e7
Showing with 2 additions and 2 deletions
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
l = 0 l = 0
r = len(num_list)-1 r = len(num_list)-1
a = 9 a = 20
while l <= r: while l <= r:
m = (l+r)//2 m = (l+r)//2
if num_list[m] == a: if num_list[m] == a:
print(m) print("找到了,索引为:",m)
exit() exit()
elif num_list[m] < a: elif num_list[m] < a:
l = m+1 l = m+1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment