#K80682. Pyramid Flower Bed
Pyramid Flower Bed
Pyramid Flower Bed
Given an integer ( n ), generate a flower bed with pyramid-shaped layers composed of numbers. Each layer ( i ) (where ( 1 \le i \le n )) is formed by listing numbers from 1 to ( i ) and then back to 1, forming a symmetric pyramid. The maximum width of the flower bed is given by ( 2n - 1 ). The output must be center aligned as shown in the examples below.
For example, when ( n = 3 ), the flower bed is: 1
1 2 1
1 2 3 2 1
Read the input from standard input (stdin) and print the result to standard output (stdout).
inputFormat
The input consists of a single integer ( n ) (( n \ge 1 )), which represents the number of layers in the flower bed. The input is provided via standard input (stdin).
outputFormat
Output the pyramid-shaped flower bed to standard output (stdout) with each row center aligned. Each row should have the numbers separated by a single space with no trailing spaces.## sample
1
1
</p>