Commit 5aba70c6 by BellCodeEditor

save project

parent a0b7a612
Showing with 8 additions and 4 deletions
...@@ -4,10 +4,13 @@ low = 0 #最低值 ...@@ -4,10 +4,13 @@ low = 0 #最低值
high = len(num_list)-1 #最高值 high = len(num_list)-1 #最高值
mid = (low + high)//2 #中间值 mid = (low + high)//2 #中间值
guess = num_list[mid] guess = num_list[mid]
if guess == num_list[mid]: while low == high:
print("找到了") if guess == num_list[mid]:
elif guess < num: break
elif guess < num:
low = mid + 1 low = mid + 1
else: else:
high = mid - 1 high = mid - 1
if low < high:
print("不存在")
print(guess) print(guess)
\ 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