Commit 4b4ed19b by BellCodeEditor

save project

parent b5bef6f5
Showing with 6 additions and 22 deletions
import random import tkinter
a=[] root = tkinter.Tk()
for i in range(1,101): root.title('注册')
a.append(i) root.geometry('400x320+500+300')
num = random.choice(a) root.mainloop()
def b (alist,num): \ No newline at end of file
low = 0
high=len(alist)-1
while low<=high:
mid=(low+high)//2
g=alist[mid]
if g == num:
return mid
elif g<num:
low=mid+1
elif g>num:
high=mid-1
return None
r=b(a,num)
print('数是:',num)
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