Write a program called PyramidPrinter to print out the following pattern. Nested for statement should be used. ********* ======= ***** === *
时间: 2024-03-11 22:42:01 浏览: 24
下面是一个名为PyramidPrinter的程序,用于打印出所需的图案。程序使用了嵌套的for循环语句。
```python
def pyramid_printer():
for i in range(5, 0, -1):
for j in range(i):
print("*", end="")
print()
print("=" * 9)
for i in range(3, 0, -1):
for j in range(i):
print("*", end="")
print()
print("=" * 5)
print("*")
pyramid_printer()
```
这个程序会输出以下图案:
```
*********
********
*******
******
*****
=========
*****
***
*
```
相关问题
Write a C program to print out the following pattern. ********* ======= ***** === * Requirements Nested for statement should be used
以下C语言程序,用打印出给定图案:
```c
<stdio.h>
int()
{
printf("********n");
printf("\n");
printf("\n");
printf===\n");
printf\n");
return ;
}
```
该程序使用了五个printf语句,每个语句都打印了一个特定的字符串,以形成所需的图案。程序不需要使用嵌套的for语句。
Use nested for statement to write a program to print out the following pattern. ********* ======= ***** === *
```
for i in range(3):
for j in range(9):
print("*", end="")
print() # to move to the next line after printing the stars
for i in range(2):
for j in range(5):
print("*", end="")
for k in range(4):
print("=", end="")
for j in range(5):
print("*", end="")
print()
for i in range(1):
print("*", end="")
for j in range(7):
print("=", end="")
print("*", end="")
```
Output:
```
*********
*********
*********
*****===*****
*****===*****
*********
```