left=1
right = 100
cnt=0
while left<=right:
mid=(left+right)//2
cnt +=i
if mid==53:
Break
elif mid<53:
left = mid+1
else:
right = mid-1
print("采用二分查找方法,在1-100中查找53需要比较()次".format(cnt))
微信扫码预览、分享更方便