Commit de38ab53 by BellCodeEditor

save project

parent c71f58a3
Showing with 16 additions and 0 deletions
x=20
num_list=[1,3,5,8,11,15,17,18,20,21]
low=0
high=len(num_list)-1
while low<=high:
y=(low+high)//2
guess=num_list[y]
if guess==x:
print("找到了,它的索引是:",y)
break
elif guess<x:
low=y+1
y=(low+high)//2
else:
high=y-1
y=(low+high)//2
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