Commit 1419ab50 by BellCodeEditor

save project

parent 845c1255
Showing with 19 additions and 7 deletions
dict={'可口可乐':3,'旺仔牛奶'4'农夫山泉'1,'辣条'3'巴西烤肉'2'果冻'4} def print_tree (height):
k=input('你想买什么?') for i in range(height):
if k in dict: print(' ' * (height - i - 1) + '*' *(2 * i + 1))
print('叮咚~您的''+k+'需要支付'+str(dict[k])+'~') print(' ' * (height - 1) + '|')
else:
print('神奇百货暂未有你想要的物品,敬请期待~') def print_decorted_tree(heght,decorations=5):
\ No newline at end of file print_tree(height)
print(' ' * (height - 1)+ '*')
for i in range(decorations):
level = i % (height - 1) + 1
pos = (level * 2 - 1) // 2 + i % 2
print(' ' * (height-level - 1) + '*' * (pos) + '0' + '*')
if _name_ == "_main_":
height = 5
decorations = 10
print_decroratted_tree(height, decorations)
\ 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