Skip to content
Advertisement

How do I size and sapce

this is what i needed and i appreciate it guys

Advertisement

Answer

For problems like these, try to associate the output with its indices (or in this case, current_row). Also, it seems like it’s better to start from 0 for this one.

max_row is 5, current_row is from 0 to 4.
There are max_row - current_row - 1 spaces on each row.
There are 2 * current_row - 1 stars on each row.
The numbers on the left is just twice current_row, or 2 * current_row. This is true for all except 0. We could use an if statement for that special case.
The numbers on the right is just left + 1, or 2 * current_row + 1.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement