Commit 1e64d827 by BellCodeEditor

save project

parent 796ce352
Showing with 16 additions and 14 deletions
a=[1,3,5,8,11,15,17,18,20,21] a=[1,3,5,8,11,15,17,18,20,21]
low=0
h=len(a)-1
shu=1 #找的数
while low<=h: def erfen(alist,num):
mid = (low+h)//2 low=0
g=a[mid] h=len(alist)-1
if g==shu: while low<=h:
print("找到了",mid) mid = (low+h)//2
break g=alist[mid]
elif g <shu: if g==num:
low = mid+1 print("找到了",mid)
elif g>shu: break
h = mid-1 elif g <num:
\ No newline at end of file low = mid+1
elif g>num:
h = mid-1
erfen(a,15)
\ 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