Commit f0a5ac30 by BellCodeEditor

auto save

parent 5bc1e8ac
Showing with 9 additions and 3 deletions
...@@ -10,9 +10,14 @@ def A(alist,num): ...@@ -10,9 +10,14 @@ def A(alist,num):
while min<=max: while min<=max:
mid=(min+max)//2 mid=(min+max)//2
caide=alist[mid] caide=alist[mid]
if caide==zhaode: if caide==num:
return mid return mid
elif caide < zhaode: elif caide < num:
min=mid+1 min=mid+1
elif caide > zhaode: elif caide > num:
max=mid-1 max=mid-1
return None
B = A(alist,num)
print("这个数是",num)
print("这个数的索引值是",B)
\ 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