Commit b091eadb by BellCodeEditor

save project

parent 23a4dc48
Showing with 7 additions and 6 deletions
...@@ -3,14 +3,15 @@ num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] ...@@ -3,14 +3,15 @@ num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
num=20 num=20
low,high=0,len(num_list) low,high=0,len(num_list)
guess=0 guess=0
while guess==num: while guess!=num:
mid=(low+high)//2 mid=(low+high)//2
guess=num_list[mid] guess=num_list[mid]
if guess==num:
print("找到了") if guess<num:
elif guess<num:
low=mid+1 low=mid+1
print(guess) print(guess)
else: else:
high=mid-1 high=mid-1
print(guess) print(guess)
\ No newline at end of file if guess==num:
print("找到了")
\ 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