一、顺序查找
'''python
list=[1,5,8,2,4]
def shunxu(list,key):
for i in range(len(list)-1):
if list[i]==key:
print("%d在列表的%d位"%(key,i))
shunxu(list,2)
'''
二、二分查找
#需有序数列
'''python
list=[1,2,4,6,8,10]
def erfen(list,key):
left=0
right=len(list)-1
while left<=right:
mid=(left+right)//2
if list[mid]==key:
return mid
elif list[mid]>=key:
right=mid-1
elif list[mid]<=key:
left=mid+1
print(erfen(list,5))
'''