#C7784. Pyramid Generation Problem
Pyramid Generation Problem
Pyramid Generation Problem
You are given a positive integer ( h ) and a character ( c ). Your task is to generate a pyramid of height ( h ) using the character ( c ). For each row ( i ) (where ( 1 \leq i \leq h )), print exactly ( 2i-1 ) characters of ( c ) such that the row is centered in a field of width ( 2h-1 ). If ( h ) is less than 1, print nothing.
For example, when ( h = 3 ) and ( c = '#' ), the expected pyramid is:
# ### #####
Note: All formulae are rendered in LaTeX format.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer ( h ), the height of the pyramid.
- The second line contains a single character ( c ) used to build the pyramid.
If ( h < 1 ), the program should output nothing.
outputFormat
Print the pyramid to standard output (stdout). Each row must be centered in a width of ( 2h-1 ) characters. Trailing spaces that are required for centering should be present, but no extra spaces should be printed.## sample
3
#
#
#####
</p>