Commit 6485bd9f by BellCodeEditor

save project

parent abfa3604
Showing with 7 additions and 9 deletions
......@@ -11,15 +11,13 @@ def binary_search(alist,num):
high=len(alist)-1
while low<=high:
mid=(low+high)//2
guess=num_list[mid]
guess=alist[mid]
if guess == num:
print("找到了")
break
return mid
elif guess < num:
low = mid + 1
else:
high = mid-1
if low>high:
print("该数不存在")
break
binary_search(alist,num )
\ No newline at end of file
high = mid-1
if low>high:
return None
print(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