#C6688. Diamond Pattern Generator
Diamond Pattern Generator
Diamond Pattern Generator
Given an odd integer , write a program that generates a diamond pattern inside a square grid of size . The diamond is composed of the character *
and is centered both vertically and horizontally in the grid.
The number of *
characters in each row is determined as follows:
- For the upper half (including the middle row), if is the zero-based index of the row (with ), then the number of stars is given by .
- For the lower half, the number of stars is given by .
All remaining positions in the row should be filled with a whitespace character. Your program should read the input from stdin and print the resulting diamond pattern to stdout, with each row on a new line.
inputFormat
The input consists of a single line containing an odd integer which represents the size of the grid.
outputFormat
Output the diamond pattern composed of *
characters. The diamond should be centered in an grid. Each row of the grid must be printed on a new line.## sample
1
*
</p>