Commit 5df8de80 by BellCodeEditor

save project

parent b250abfe
Showing with 37 additions and 2 deletions
# 使用二分查找法,找出9和20在列表里面的索引
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
\ No newline at end of file
num_list = [1,2,3, 5, 8, 11, 15, 17, 18, 20, 21]
def j(a,b):
low=0
high=len(a)-1
while True:
min=(high+low)//2
g=a[min]
if g==b:
return min
elif g>b:
high=min-1
else:
low=min+1
c=j(num_list,8)
print(c)
\ No newline at end of file
import turtle
pen=turtle.Pen()
def a(b):
for i in range(1,b,3):
pen.forward(i)
pen.left(90)
pen.forward(i)
s=a(100)
turtle.done()
\ No newline at end of file
def f(n):
if n==1:
return 1
else:
num=f(n-1)*n
return num
v=f()
print(v)
\ 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