Commit 6b2b98bd by BellCodeEditor

save project

parent 9bc20411
Showing with 2 additions and 5 deletions
# 使用二分查找法,找出9和20在列表里面的索引
zhaode = 200 zhaode=int(input("请输入你要找的数:"))
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
min = 0 min = 0
max =len(num_list)-1 max =len(num_list)-1
...@@ -13,6 +12,4 @@ while min<=max: ...@@ -13,6 +12,4 @@ while min<=max:
elif caide < zhaode: elif caide < zhaode:
min=mid+1 min=mid+1
elif caide > zhaode: elif caide > zhaode:
man=mid-1 max=mid-1
else:
print("菜就多练,没有这个数",mid)
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