Commit be1521ed by BellCodeEditor

save project

parent 0cf01401
Showing with 19 additions and 11 deletions
bingo_num=20
num_list=[1,3,5,8,11,15,17,18,20,21]
high=len(num_list)
low=num_list(0)
www=(high+low)//2
guess=num_list[www]
if guess==num:
print("找到了")
eilf guess<num:
low=www+1
else:
high=www-1
\ No newline at end of file
low=0
high=len(num_list)-1
while low<=high:
www=(high+low)//2
guess=num_list[www]
if guess==bingo_num:
print("找到了,它在列表的索引是:",www)
break
elif guess<bingo_num:
low=www+1
elif guess>bingo_num:
high=www-1
\ 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