Pola piramida angka berongga dengan python

Jalankan
```num = 8
k = 0
for i in range(1, num + 1):
# printing left spaces in rows
for j in range(i, num):
print(" ", end="")

while k != (2 * i - 1):
# printing left/right boundaries
if k == 0 or k == 2 * i - 2:
print("*", end="")
# printing spaces in the middle of the triangle
else:
print(" ", end="")
k = k + 1

k = 0
print()

# printing bottom boundary of the triangle
for i in range(0, 2 * num - 1):
print("*", end="")
```

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
20
```   *
* *
*   *
*     *
*   *
* *
*   ```
21
```   *
* *
*   *
*     *
*   *
* *
*   ```
22
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```     #
# #
#   #
#     #
#       #
#         #
###########```
28
```   *
* *
*   *
*     *
*   *
* *
*   ```
25
```   *
* *
*   *
*     *
*   *
* *
*   ```
26
```     #
# #
#   #
#     #
#       #
#         #
###########```
28
```   *
* *
*   *
*     *
*   *
* *
*   ```
28________3

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
32

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
35
```   *
* *
*   *
*     *
*   *
* *
*   ```
21
```   *
* *
*   *
*     *
*   *
* *
*   ```
22
```   *
* *
*   *
*     *
*   *
* *
*   ```
38

`// CPP program to print a hollow pyramid pattern`1

```   *
* *
*   *
*     *
*   *
* *
*   ```
40
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```   *
* *
*   *
*     *
*   *
* *
*   ```
42
```   *
* *
*   *
*     *
*   *
* *
*   ```
43
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
45

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
48

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`#include `0
```   *
* *
*   *
*     *
*   *
* *
*   ```
51
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```     #
# #
#   #
#     #
#       #
#         #
###########```
49
```   *
* *
*   *
*     *
*   *
* *
*   ```
55
```   *
* *
*   *
*     *
*   *
* *
*   ```
20
```   *
* *
*   *
*     *
*   *
* *
*   ```
57
```     #
# #
#   #
#     #
#       #
#         #
###########```
28________3______59

```   *
* *
*   *
*     *
*   *
* *
*   ```
62
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
16 _______________23
```   *
* *
*   *
*     *
*   *
* *
*   ```
____66 ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________g

`#include `5

```   *
* *
*   *
*     *
*   *
* *
*   ```
40
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```   *
* *
*   *
*     *
*   *
* *
*   ```
79
```   *
* *
*   *
*     *
*   *
* *
*   ```
43
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
45

`// CPP program to print a hollow pyramid pattern`1`using`0

```   *
* *
*   *
*     *
*   *
* *
*   ```
85

`#include `5

```   *
* *
*   *
*     *
*   *
* *
*   ```
40
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```   *
* *
*   *
*     *
*   *
* *
*   ```
42
```   *
* *
*   *
*     *
*   *
* *
*   ```
43
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
45

`// CPP program to print a hollow pyramid pattern`1

```   *
* *
*   *
*     *
*   *
* *
*   ```
15
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
15________3______26
```     #
# #
#   #
#     #
#       #
#         #
###########```
28

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
15
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```     #
# #
#   #
#     #
#       #
#         #
###########```
23________315______4

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
40
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
06
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
07

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
10

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
20
```   *
* *
*   *
*     *
*   *
* *
*   ```
21
```   *
* *
*   *
*     *
*   *
* *
*   ```
22
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```     #
# #
#   #
#     #
#       #
#         #
###########```
23
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
18_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ jelas

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
40
```   *
* *
*   *
*     *
*   *
* *
*   ```
23
```   *
* *
*   *
*     *
*   *
* *
*   ```
79
```   *
* *
*   *
*     *
*   *
* *
*   ```
43
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```   *
* *
*   *
*     *
*   *
* *
*   ```
45

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
_32

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
21
```   *
* *
*   *
*     *
*   *
* *
*   ```
16
```     #
# #
#   #
#     #
#       #
#         #
###########```
04

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
_36

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
_37

C#

`using`

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
39

`void`5 `void`1 `void`2

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`void`5 `void`6 `void`
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
47

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
1
```     #
# #
#   #
#     #
#       #
#         #
###########```
8

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
0

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`void`6 `void`
```     #
# #
#   #
#     #
#       #
#         #
###########```
0
```     #
# #
#   #
#     #
#       #
#         #
###########```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
5

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
9

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
2
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
3

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`// CPP program to print a hollow pyramid pattern`1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
7

`// CPP program to print a hollow pyramid pattern`1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1 `// CPP program to print a hollow pyramid pattern`0

`#include `5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
81`// CPP program to print a hollow pyramid pattern`3
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`// CPP program to print a hollow pyramid pattern`1

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`8

`// CPP program to print a hollow pyramid pattern`1`#include `0 `#include `1

`#include `5`#include `3 `#include `4

```     #
# #
#   #
#     #
#       #
#         #
###########```
_62
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
81`#include `7
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `5`using`0

```     #
# #
#   #
#     #
#       #
#         #
###########```
_62
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
81`// CPP program to print a hollow pyramid pattern`3
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `5`using`6

`#include `5`// CPP program to print a hollow pyramid pattern`4

`// CPP program to print a hollow pyramid pattern`1

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`// CPP program to print a hollow pyramid pattern`1`namespace`0

`// CPP program to print a hollow pyramid pattern`_1

________315

```     #
# #
#   #
#     #
#       #
#         #
###########```
_358_______3

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`16

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`namespace`7

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1 `std;`0

`// CPP program to print a hollow pyramid pattern`1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
81`#include `7
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`// CPP program to print a hollow pyramid pattern`_33

PHP

`// CPP program to print a hollow pyramid pattern`_34

`// CPP program to print a hollow pyramid pattern`_35

`// CPP program to print a hollow pyramid pattern`_36

`// CPP program to print a hollow pyramid pattern`_37

```     #
# #
#   #
#     #
#       #
#         #
###########```
0`// CPP program to print a hollow pyramid pattern`39
```     #
# #
#   #
#     #
#       #
#         #
###########```
61

```     #
# #
#   #
#     #
#       #
#         #
###########```
_5

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`// CPP program to print a hollow pyramid pattern`43 `// CPP program to print a hollow pyramid pattern`44

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
3

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
23`// CPP program to print a hollow pyramid pattern`51 `// CPP program to print a hollow pyramid pattern`52`// CPP program to print a hollow pyramid pattern`51 `// CPP program to print a hollow pyramid pattern`54`// CPP program to print a hollow pyramid pattern`39`// CPP program to print a hollow pyramid pattern`4`// CPP program to print a hollow pyramid pattern`158_____

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
7

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
23`// CPP program to print a hollow pyramid pattern`67
```   *
* *
*   *
*     *
*   *
* *
*   ```
16`// CPP program to print a hollow pyramid pattern`51`// CPP program to print a hollow pyramid pattern`______________________________________________________________________________________________________________________________________________________________________________________________________________

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`80 `// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`// CPP program to print a hollow pyramid pattern`8

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`#include `0
```   *
* *
*   *
*     *
*   *
* *
*   ```
23`// CPP program to print a hollow pyramid pattern`43 `// CPP program to print a hollow pyramid pattern`92`// CPP program to print a hollow pyramid pattern`51 `// CPP program to print a hollow pyramid pattern`94

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`// CPP program to print a hollow pyramid pattern`1`#include `3

```   *
* *
*   *
*     *
*   *
* *
*   ```
23`// CPP program to print a hollow pyramid pattern`43 `#include `01`// CPP program to print a hollow pyramid pattern`43 `#include `03

`#include `04`// CPP program to print a hollow pyramid pattern`51 `#include `06

`#include `5`// CPP program to print a hollow pyramid pattern`80 `#include `7`// CPP program to print a hollow pyramid pattern`4

`// CPP program to print a hollow pyramid pattern`1`using`0

`#include `5`// CPP program to print a hollow pyramid pattern`80 `// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`43`#include `19

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`// CPP program to print a hollow pyramid pattern`43 `// CPP program to print a hollow pyramid pattern`44

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`namespace`3

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`// CPP program to print a hollow pyramid pattern`80 `#include `30`// CPP program to print a hollow pyramid pattern`4

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`namespace`7

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
23`// CPP program to print a hollow pyramid pattern`51 `// CPP program to print a hollow pyramid pattern`44`// CPP program to print a hollow pyramid pattern`51 `#include `43`// CPP program to print a hollow pyramid pattern`39 `#include `45`// CPP program to print a hollow pyramid pattern`515

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`// CPP program to print a hollow pyramid pattern`80 `#include `7`// CPP program to print a hollow pyramid pattern`4

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `_57

`// CPP program to print a hollow pyramid pattern`_39 `#include `59

```     #
# #
#   #
#     #
#       #
#         #
###########```
0`// CPP program to print a hollow pyramid pattern`39
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `_63

`#include `_64

Javascript

`#include `_65

`#include `66`#include `67

`#include `66`#include `69

```     #
# #
#   #
#     #
#       #
#         #
###########```
8

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
0

`#include `66`// CPP program to print a hollow pyramid pattern`37

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
36

`#include `_66

```     #
# #
#   #
#     #
#       #
#         #
###########```
5

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`#include `69
```   *
* *
*   *
*     *
*   *
* *
*   ```
9

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
2
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
3

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`#include `_87

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
7

`#include `_87

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1 `#include `91

`#include `_87

```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`// CPP program to print a hollow pyramid pattern`1`#include `95`#include `96

```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `_87

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `_87

`#include `87`// CPP program to print a hollow pyramid pattern`8

________316

```   *
* *
*   *
*     *
*   *
* *
*   ```
_316_______0 `using`05

`#include `_87

```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`// CPP program to print a hollow pyramid pattern`1`#include `3 `#include `4

________316______5`#include `95`#include `7

```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`// CPP program to print a hollow pyramid pattern`1`using`0

`#include `5`#include `95`#include `96

```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`// CPP program to print a hollow pyramid pattern`1`using`6

`#include `_87

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `87`namespace`0

`#include `87`#include `95`using`29

```     #
# #
#   #
#     #
#       #
#         #
###########```
2`namespace`3

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6`namespace`7

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1 `using`39

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`#include `87`#include `95`#include `7

```     #
# #
#   #
#     #
#       #
#         #
###########```
2

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
6
```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `_66

`#include `66`using`52

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6`using`54

Keluaran

```     #
# #
#   #
#     #
#       #
#         #
###########```
_

Kompleksitas waktu. O(N^2), Algoritma ini memiliki kompleksitas waktu O(N^2), di mana N adalah jumlah baris. Ini karena kita mengulangi baris dan kolom pola, yang membutuhkan waktu O(N^2) untuk menyelesaikannya

Kompleksitas ruang. O(1), Algoritma ini tidak memerlukan ruang tambahan, sehingga kompleksitas ruangnya adalah O(1)

2. Berlian Berongga

Catatan. Untuk input genap, cetak pola untuk n-1

Contoh

Memasukkan. 1

Keluaran

Untuk n=1

Memasukkan. 7

Keluaran

Untuk n=7

Memasukkan. 9

Keluaran

Untuk n=9

Mendekati. Untuk mencetak berlian, kita perlu mencetak spasi sebelum bintang dan setelah bintang untuk mencapai jarak bintang yang terus bertambah

Untuk mencetak bentuk kotak kita perlu mencetak '-' untuk i==1 (baris pertama) & i==n (baris terakhir) dan '. ’ untuk j==1 (kolom pertama) dan j==n (kolom terakhir)

Algoritma. 1. Jika n adalah kenaikan ganjil n

2. Temukan pertengahan = n/2

3. Lintasi dari 1 hingga pertengahan untuk mencetak separuh atas pola (katakanlah i)

4. Lintasi dari 1 ke mid-i untuk mencetak spasi untuk kotak terluar paling kiri atas (katakanlah j)

5. Jika (i==1) cetak '*' (karena untuk baris pertama kita hanya membutuhkan satu bintang)

6. lain cetak '*' dan lintasi dari 1 ke 2*i-3 untuk mencetak spasi untuk berlian berongga (katakanlah j) dan cetak '*' setelah loop selesai

7. Lintasi dari 1 ke mid-i untuk mencetak spasi lagi untuk kotak terluar paling kanan atas (katakanlah j)

8. Tutup loop pada langkah 3

9. Lintasi dari pertengahan+1 ke n-1 untuk mencetak separuh bawah pola (katakanlah i)

4. Lintasi dari 1 ke i-mid untuk mencetak ruang untuk kotak terluar paling kiri bawah (katakanlah j)

5. Jika (i==n-1) cetak '*' (karena untuk baris terakhir kita hanya membutuhkan satu bintang)

6. lain cetak '*' dan lintasi dari 1 ke 2*(n-i)-3 untuk mencetak spasi untuk berlian berongga (katakanlah j) dan cetak '*' setelah loop selesai

7. Lintasi dari 1 ke i-mid untuk mencetak spasi lagi untuk kotak terluar paling kanan bawah (katakanlah j)

8. Tutup loop pada langkah 9

C++14

`using`_55

`using` `namespace` `std;`

`using`_59

`void`

```     #
# #
#   #
#     #
#       #
#         #
###########```
0
```     #
# #
#   #
#     #
#       #
#         #
###########```
1`using`63

```     #
# #
#   #
#     #
#       #
#         #
###########```
_5

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
1 `using`67

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`#include `3`using`70`using`71

`#include `66`using`73

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6`using`75

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6`using`78

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`using`81

`#include `66

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`using`84`using`85

`using`86`using`87`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`_86

________316

```   *
* *
*   *
*     *
*   *
* *
*   ```
_316_______3`using`93

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1`using`0
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4`namespace`06

`using`86

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`namespace`09`namespace`10

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`2`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`86

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `66

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`using`84`namespace`26

`using`86`using`87`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`_86

`#include `66`namespace`2

`namespace`_34

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`namespace`_34

________358

```   *
* *
*   *
*     *
*   *
* *
*   ```
_358_______38

`namespace`_34

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`namespace`41

`namespace`_42

`#include `66

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`namespace`45`using`85

`using`86`using`87`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`_86

________316

```   *
* *
*   *
*     *
*   *
* *
*   ```
_316_______3`namespace`54

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1`using`0
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4`namespace`06

`using`86

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`namespace`70`namespace`10

`// CPP program to print a hollow pyramid pattern`1`// CPP program to print a hollow pyramid pattern`2`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`86

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`using`86`// CPP program to print a hollow pyramid pattern`2`using`96`// CPP program to print a hollow pyramid pattern`4

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`#include `66

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`namespace`45`namespace`26

`using`86`using`87`// CPP program to print a hollow pyramid pattern`3`// CPP program to print a hollow pyramid pattern`4

`using`_86

`#include `66`namespace`2

`namespace`_34

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`namespace`_98

```     #
# #
#   #
#     #
#       #
#         #
###########```
1 `std;`00

`namespace`_34

```     #
# #
#   #
#     #
#       #
#         #
###########```
1 `std;`03

`namespace`_34

```   *
* *
*   *
*     *
*   *
* *
*   ```
0

```   *
* *
*   *
*     *
*   *
* *
*   ```
1

`std;`_07

Jawa

`std;`_08

`void`1 `void`2

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6

`using`_59

`void`6 `void`

```     #
# #
#   #
#     #
#       #
#         #
###########```
0
```     #
# #
#   #
#     #
#       #
#         #
###########```
1
```   *
* *
*   *
*     *
*   *
* *
*   ```
5

```     #
# #
#   #
#     #
#       #
#         #
###########```
_5

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```     #
# #
#   #
#     #
#       #
#         #
###########```
1 `using`67

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`#include `3`std;`24
```     #
# #
#   #
#     #
#       #
#         #
###########```
49`std;`_26
```     #
# #
#   #
#     #
#       #
#         #
###########```
28
```     #
# #
#   #
#     #
#       #
#         #
###########```
61`using`71

`#include `66`using`73

```     #
# #
#   #
#     #
#       #
#         #
###########```
6`std;`33
```     #
# #
#   #
#     #
#       #
#         #
###########```
49`// CPP program to print a hollow pyramid pattern`4

`std;`_36

```     #
# #
#   #
#     #
#       #
#         #
###########```
_6`using`78

```     #
# #
#   #
#     #
#       #
#         #
###########```
6
```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1
```     #
# #
#   #
#     #
#       #
#         #
###########```
27
```     #
# #
#   #
#     #
#       #
#         #
###########```
28`std;`43

`#include `66

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`std;`46
```     #
# #
#   #
#     #
#       #
#         #
###########```
28`std;`48`using`85

`using`86

```     #
# #
#   #
#     #
#       #
#         #
###########```
39`// CPP program to print a hollow pyramid pattern`3
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `_87

`#include `66`#include `3`std;`57

```     #
# #
#   #
#     #
#       #
#         #
###########```
28`std;`59

`using`86

```     #
# #
#   #
#     #
#       #
#         #
###########```
39`using`96
```     #
# #
#   #
#     #
#       #
#         #
###########```
2

`#include `66

```   *
* *
*   *
*     *
*   *
* *
*   ```
1`using`0
```     #
# #
#   #
#     #
#       #
#         #
###########```
5

`using`86

```     #
# #
#   #
#     #
#       #
#         #
###########```
39`using`96
```     #
# #
#   #
#     #
#       #
#         #
###########```
2`namespace`06

`using`86

```-----*-----
|   * *   |
|  *   *  |
| *     * |
|*       *|
*         *
|*       *|
| *     * |
|  *   *  |
|   * *   |
-----*-----```
1`std;`46
```     #
# #
#   #
#     #
#       #
#         #
###########```
28`std;`_77
```     #
# #
#   #
#     #
#       #
#         #
###########```
49`void`54`std;`80`std;`81`namespace`_10

Bagaimana cara mencetak pola bintang piramida terbalik berongga dengan Python?

Pola bintang segitiga siku-siku berongga dengan python .
Awal
Ambil jumlah baris sebagai input dari pengguna dan simpan ke dalam num
Jalankan loop 'i' beberapa kali untuk mengulangi semua baris yang Mulai dari i=0 hingga num
Jalankan loop bersarang di dalam loop utama untuk ruang pencetakan yang dimulai dari j=0 hingga i

Bagaimana Anda membuat pola piramida dengan Python?

Kode Sumber .
Pertama, kami mendapatkan tinggi baris piramida dari pengguna
Di loop pertama, kami beralih dari i = 0 ke i = baris
Di loop kedua, kami mencetak angka mulai dari 1 hingga j , di mana j berkisar dari 0 hingga i
Setelah setiap iterasi dari loop pertama, kami mencetak baris baru

Bagaimana Anda mencetak pola segitiga berongga?

scanf("%u",&baris);

Bagaimana Anda mencetak segitiga siku-siku berongga dengan Python?

Deskripsi .
# Ulangi baris. untuk i dalam rentang(1, n+1)
# Ulangi kolom. untuk j dalam rentang(1, n+1)
jika (i == j) atau (j == 1) atau (i == n). cetak("*", akhir=" ")
kalau tidak. cetak(" ", akhir=" ")