Commit 66ce735c by BellCodeEditor

save project

parent 3ad8cd5e
Showing with 9 additions and 2 deletions
import random
alist = []
for i in random(1,101):
alist.append(i)
def binary_search(alist,num) def binary_search(alist,num)
low = 0 low = 0
hight = len(num_list)-1 hight = len(num_list)-1
...@@ -6,10 +10,12 @@ while low <= high: ...@@ -6,10 +10,12 @@ while low <= high:
hight=(len(num_list)) hight=(len(num_list))
low=num_list(0) low=num_list(0)
if guess == num: if guess == num:
print("找到了,他摘类别",mid)
break
elif guess < num: elif guess < num:
low = mid + 1 low = mid + 1
else: else:
hight = mid -1 hight = mid -1
return None
result = binary_search(alist,num)
print("老师跟谁"num)
print("它在来啊哈欠"result)
\ 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