Commit 2f180ea2 by BellCodeEditor

auto save

parent 57009926
Showing with 6 additions and 5 deletions
...@@ -3,13 +3,13 @@ b=8 ...@@ -3,13 +3,13 @@ b=8
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
whilt l <=h: while l <= h:
m=(l+h)// m=(l+h)//2
g=nlist[m] g=nlist[m]
if g == d: if g == b:
print("找到了,索引值为",m) print("找到了,索引值为",m)
break break
elif g < d: elif g < b:
l = m+1 l = m+1
elif g > d: elif g > b:
h = m-1 h = m-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