擅长:python、mysql、java
<p>这个是升序还是降序打印呢?</p>
<pre><code>def stars(n, descending=True):
if (descending):
print '*'*n
if n==1:
if not descending:
print '*'
return
stars(n-1, descending)
if not descending:
print '*'*n
stars(5)
print
stars(5, descending=False)
</code></pre>
<h3>输出:</h3>
<pre><code>*****
****
***
**
*
*
**
***
****
*****
</code></pre>