使用循环编程实现以下图形: * *** ***** *** *
时间: 2023-09-03 18:10:43 浏览: 107
代码如下:
```
for i in range(1, 4):
for j in range(i):
print("*", end="")
for k in range(2*i-2):
print(" ", end="")
for j in range(i):
print("*", end="")
print()
for i in range(2, 0, -1):
for j in range(i):
print("*", end="")
for k in range(2*i-2):
print(" ", end="")
for j in range(i):
print("*", end="")
print()
```
输出结果为:
```
* *** *
** ******
*********
** ******
* *** *
```
阅读全文