Commit 76fbe6c2 by BellCodeEditor

save project

parent 083da691
Showing with 5 additions and 4 deletions
...@@ -5,13 +5,13 @@ mina=0 ...@@ -5,13 +5,13 @@ mina=0
maxa=len(num_list)-1 maxa=len(num_list)-1
while mina<=maxa: while mina<=maxa:
mid=(mina+maxa)//2 mid=(mina+maxa)//2
g=num_list[mid] gnum=num_list[mid]
if g==num: if gnum==num:
print('索引为:',mid) print('索引为:',mid)
break break
elif g<num: elif gnum<num:
mina=mid+1 mina=mid+1
else g>num: else :
maxa=mid-1 maxa=mid-1
if mina>maxa: if mina>maxa:
print('不存在这个数') print('不存在这个数')
\ 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