Commit f1802b65 by BellCodeEditor

auto save

parent 200f04cf
Showing with 21 additions and 0 deletions
......@@ -4,6 +4,26 @@ alist = []
for i in range(1, 101):
alist.append(i)
num = random.choice(alist)
def binary_search(alist,num)
num=3
guess_num=1
num_list=[1,3,5,8,11,15,17,18,20,21]
low=0
high=len(num_list)-1
while low<=high:
mid=(low+high)//2
num=num_list[mid]
if mid==guess_num:
print("QWQ找到了qwq")
print(114514)
print("yase")
break
elif mid<guess_num:
low=mid+1
else:
high=mid-1
# 请完善二分查找函数binary_search(),查找出num在列表alist里面的索引位置
def binary_search(alist,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