Commit 8cbbfa4b by BellCodeEditor

save project

parent 1104f442
Showing with 22 additions and 2 deletions
# 使用二分查找法,找出9和20在列表里面的索引 # 使用二分查找法,找出9和20在列表里面的索引
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] num_list = []
\ No newline at end of file for i in range(1,101):
num_list.append(i)
def lll(num):
x=0
e=len(num_list)-1
while True:
ghwoihhhhhhhhhh=(x+e)//2
mrfz = num_list[ghwoihhhhhhhhhh]
if mrfz == num :
print("sb")
print(ghwoihhhhhhhhhh)
break
elif mrfz < num:
x = ghwoihhhhhhhhhh + 1
else:
e = ghwoihhhhhhhhhh - 1
if x>e:
print("gu")
break
lll(3)
\ 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