#C13868. Diamond Pattern Printer
Diamond Pattern Printer
Diamond Pattern Printer
You are given an odd positive integer n. Your task is to print a diamond pattern consisting of n lines using asterisks (*) and spaces. The diamond is centered so that each line contains leading and trailing spaces ensuring symmetry.
The number of asterisks in the i-th line (0-indexed) is determined as follows:
\[ \text{stars} = \begin{cases} 1+2i & \text{if } i \leq \frac{n-1}{2} \\ 1+2(n-i-1) & \text{if } i > \frac{n-1}{2} \end{cases} \]
The number of spaces on each side is \(\frac{n - \text{stars}}{2}\). If the input n is even, the program should print an error message: "Input must be an odd number".
inputFormat
The input consists of a single line containing one integer n read from standard input.
outputFormat
If n is odd, output the diamond pattern over n lines. Each line should contain exactly n characters (a mix of spaces and asterisks) followed by a newline character. If n is even, output the error message "Input must be an odd number" followed by a newline.
## sample5
*
</p>