#C8217. Diamond Pattern Printer
Diamond Pattern Printer
Diamond Pattern Printer
You are given a single integer n (with 1 ≤ n ≤ 20) from standard input. Your task is to print a diamond pattern using asterisks ('*'). The diamond consists of 2n - 1
lines. For a given line index i (ranging from -n+1
to n-1
), the number of spaces to print is |i|
, and the number of asterisks is given by the formula: $$2(n - |i|) - 1$$. Each line should be printed on a new line, and the diamond must be centered based on the widest part of the pattern.
Example:
Input: 3Output: *
If the input is not within the valid range, the program should output an error message: "Input should be between 1 and 20 inclusive."
inputFormat
The input consists of a single integer n provided via standard input.
Constraints: 1 ≤ n ≤ 20
outputFormat
Output the diamond pattern to standard output. If the input is invalid, output the error message: "Input should be between 1 and 20 inclusive."
## sample3
*
</p>