Commit b1439bba by BellCodeEditor

save project

parent e521e0cb
Showing with 3 additions and 6 deletions
......@@ -9,20 +9,17 @@ num = random.choice(alist)
def binary_search(alist,num):
low=0
high=len(alist)-1
mid=(low+high)//2
while low<=high:
mid=(high+low)//2
guess=alist[mid]
if guess==num:
print('找到了',mid)
break
return mid
elif guess<num:
low=mid+1
else:
high=mid-1
binary_search(alist,10)
s=binary_search(alist,10)
print('找到了',s)
......
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