Pattern HourGlass

https://hack.codingblocks.com/contests/c/474/1417
https://ide.codingblocks.com/#/s/26919

how to print numbers instead of stars.
Please help.

1 Like

Your code is wrong even for stars.
For input=5, you have to print 11 rows as per question, but your code prints only 9 rows. Try to rectify it.
To print numbers instead of stars, take a separate variable like val. Initialise it everytime you reach a new row, then decrease its value till the middle of row and then again increase it by 1, till the end of row.
try breaking the problem in two sub-parts, lower and upper half, and then solve it again.