def binary_search(arr, k):
left, right = 0, len(arr) - 1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == k:
return True
elif arr[mid] < k:
left = mid + 1
else:
right = mid - 1
return False
def main():
arr = [85, 63, 52, 34, 25, 17, 6]
k = 6
result = binary_search(sorted(arr), k)
if result:
print(f" {k} 存在数组中")
else:
print(f" {k} 不存在数组中")
if __name__ == "__main__":
main()