Commit b2ee97cf by BellCodeEditor

save project

parent d97dcc2a
Showing with 3 additions and 3 deletions
# 使用二分查找法,找出9和20在列表里面的索引 # 使用二分查找法,找出9和20在列表里面的索引
num_list = [1, 3, 5, 8, 9, 11, 15, 17, 18, 20, 21] num_list = [1, 3, 5, 8, 9, 11, 15, 17, 18, 20, 21, 36, 44, 55, 57]
index = 0 index = 0
bingo_num = [9,20] bingo_num = [9, 20, 55]
low,high = 0,len(num_list) - 1 low,high = 0,len(num_list) - 1
while index < 2: while index < 3:
low,high = 0,len(num_list) - 1 low,high = 0,len(num_list) - 1
while low <= high: while low <= high:
mid = (low + high) mid = (low + high)
......
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