#t1140. 星号等腰三角形
星号等腰三角形
Isosceles Triangle of Stars
Problem Description
The right triangle from before only asked you to control how many stars each row printed; an isosceles triangle also needs leading spaces, which makes it a classic first exercise on nested loops: the outer loop walks over the rows, while the inner loops handle the spaces and then the stars of that row.
Concretely, for a triangle with rows, row () must:
- print spaces first;
- then print copies of
*; - then move to the next line.
For example, with :
*
***
*****
Read and print the corresponding isosceles triangle.
Input Format
One line containing a positive integer .
Output Format
lines forming the triangle exactly as described. The number of leading spaces on each line must follow the rule exactly.
Sample Input
3
Sample Output
*
***
*****
Constraints
For 100% of the test data, .
Hint: you may write two nested loops, or think of it in terms of string(n - i, ' '). Note that the last row (row ) has no leading spaces.