Commit 2535aa02 by BellCodeEditor

save project

parent 57669553
Showing with 13 additions and 3 deletions
......@@ -7,6 +7,15 @@ num = random.choice(alist)
def binary_search(alist,num):
low = 0
right = low(alist)
mid = (low + right) // 2
if
right = len(alist)-1
while low <=right:
mid = (low+right) // 2
guess_num = alist[mid]
if guess_num == num:
print("找到了:",mid)
break
elif guess_num < num:
low = mid + 1
elif guess_num > num:
right = mid - 1
binary_search(alist,num)
\ No newline at end of file
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