标签:item turn one 二分 pytho int 序列 else python
在数组中查找符合的数字,并返回序列号
def find(list, item):
low =0
hith =len(list)-1
while low <= hith:
mid =int((low + hith) /2)
if list[mid] == item:
return mid
if list[mid] < item:
low = mid +1
else:
hith = hith -1
return None
list = [1,2,3,4,5,6,7,8,9]
item =7
print(find(list, item))
标签:item turn one 二分 pytho int 序列 else python
原文地址:https://www.cnblogs.com/April-Chou-HelloWorld/p/11563548.html