每次打印一个“*” 打印菱形沙漏
时间: 2023-05-13 17:05:41 浏览: 117
以下是打印菱形沙漏的代码:
```python
n = int(input("请输入菱形沙漏的大小:"))
for i in range(n):
for j in range(n-i-1):
print(" ", end="")
for j in range(2*i+1):
print("*", end="")
print()
for i in range(n-2, -1, -1):
for j in range(n-i-1):
print(" ", end="")
for j in range(2*i+1):
print("*", end="")
print()
```
输入一个数字,即可打印出对应大小的菱形沙漏。
阅读全文