Commit e8f08610 by BellCodeEditor

auto save

parent e720e92f
Showing with 55 additions and 2 deletions
# 使用二分查找法,找出9和20在列表里面的索引 # 使用二分查找法,找出9和20在列表里面的索引
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
\ No newline at end of file low=0
high=len(num(list)-1)
mid=(low+high)//2
while True:
if 20 in num_list[:mid]:
num_list.
high=mid
else:
num_list.pop(mid:)
low=mid
if high==low and low==mid:
print("找到了")
print(low)
break
import turtle
import random
pen=turtle.Pen()
pen.color("sandybrown")
sc=turtle.Screen()
sc.bgcolor("wheat")
pen.left(90)
pen.up()
pen.backward(300)
pen.down()
def tree(n):
if n>0:
if n<=12:
color_list=["snow","pink"]
colors=random.choice(color_list)
pen.pencolor(colors)
pen.pensize(n/3)
else:
pen.pensize(n/10)
pen.pencolor("sandybrown")
angle=random.randint(0,30)
length=random.randint(1,15)
pen.forward(n)
pen.right(angle)
tree(n-length)
pen.left(angle*2)
tree(n-length)
pen.right(angle)
pen.up()
pen.backward(n)
pen.down()
tree(100)
turtle.done()
\ 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