Commit eb418ab8 by BellCodeEditor

save project

parent 773208ac
Showing with 13 additions and 9 deletions
......@@ -2,15 +2,19 @@
import random
for i in range(1,101):
num_list.append(i)
low=0
high=len(num_list)-1
num=20
while low>hige:
mid = (low+high) // 2
if mid == num:
print("找到了")
num=random.choice(num_list)
def binary_search(alist,num):
low=0
high=len(num_list)-1
while low<=high:
mid = low+high // 2
guess=num[mid]
if mid == guess:
return mid
elif mid < num:
low = mid+1
else:
high = mid-1
print(mid)
\ No newline at end of file
result binary_search(i,num)
\ 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