Commit 3c33a2af by BellCodeEditor

save project

parent cfcb3c67
Showing with 2 additions and 2 deletions
# 使用二分查找法,找出9和20在列表里面的索引 # 使用二分查找法,找出9和20在列表里面的索引
b=8 b=21
nlist = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] nlist = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
l=0 l=0
h=len(nlist)-1 h=len(nlist)-1
...@@ -12,7 +12,7 @@ while l<=h: ...@@ -12,7 +12,7 @@ while l<=h:
break break
elif g < b: elif g < b:
l=m+1 l=m+1
elifg>b: elif g >b:
h=m-1 h=m-1
......
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