Commit 93243220 by BellCodeEditor

save project

parent 569fd8fa
Showing with 7 additions and 7 deletions
import random
alist=[]
a=[]
for i in range(1,101):
alist.append(i)
num = random.choice(alist)
def binary_search (alist,num):
a.append(i)
num = random.choice(a)
def b (alist,num):
low = 0
high=len(alist)-1
while low<=high:
......@@ -16,6 +16,6 @@ def binary_search (alist,num):
elif g>num:
high=mid-1
return None
result=binary_search(alist,num)
r=b(a,num)
print('数是:',num)
print('索引:',result)
\ No newline at end of file
print('索引:',r )
\ 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