题解 | #递归画图# !!!!重点
递归画图
http://www.nowcoder.com/practice/d01d668861f84471872ff0e9c958cae2
# n1记录" "的数量, n2记录"#"的数量, c记录层次(1,2,3,...7)
def paint(n1,n2,c):
#前三层
if c < 4:
print(" "*n1+"#"*n2)
return paint(n1-1,n2+2,c+1)
# 后四层
elif 4<= c <=7:
print(" "*n1+"#"*n2)
return paint(n1+1, n2-2, c+1)
paint(4, 1, 1)