1.编程序输出图形:(使用循环结构)* * ****** *** * ***
时间: 2024-01-17 20:18:51 浏览: 90
以下是使用循环结构编写程序输出图形的示例代码:
```python
# 输出矩形
for i in range(5):
for j in range(6):
print("*", end="")
print()
# 输出椭圆
for i in range(5):
for j in range(6):
if (i == 0 or i == 4) and (j == 0 or j == 5):
print(" ", end="")
else:
print("*", end="")
print()
# 输出箭头
for i in range(5):
for j in range(6):
if i == 0 and (j == 0 or j == 5):
print(" ", end="")
elif i == 1 and (j == 1 or j == 4):
print(" ", end="")
elif i == 2 and (j == 2 or j == 3):
print(" ", end="")
else:
print("*", end="")
print()
# 输出菱形
for i in range(5):
for j in range(5-i):
print(" ", end="")
for k in range(2*i+1):
print("*", end="")
print()
for i in range(4):
for j in range(i+1):
print(" ", end="")
for k in range(7-2*i):
print("*", end="")
print()
```
阅读全文