Star Pyramid Pattern
Print a centered pyramid of stars with the given number of rows, using nested loops.
Example for 4 rows:
*
***
*****
*******Approach: for row i (starting at 1), print (rows - i) leading spaces followed by (2*i - 1) stars.
Input: One line: the number of rows (a whole number).
Output: rows lines forming a centered star pyramid, as shown above.
4
* *** ***** *******
- 1 <= rows <= 50
Hint 1
Row i needs (rows - i) leading spaces and (2*i - 1) stars.
Hint 2
String repetition works with *: " " * 3 gives three spaces, "*" * 5 gives five stars.
Hint 3
Build the whole line as one string, e.g. " " * (rows - i) + "*" * (2 * i - 1), then print it.
For each row i from 1 to rows, the number of leading spaces is rows - i and the number of stars is 2i - 1 (the odd numbers 1, 3, 5, ...). Printing " " (rows - i) + "" (2 * i - 1) on each iteration builds the pyramid one row at a time.