Commit be1521ed by BellCodeEditor

save project

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