So I am able to print the first 4 lines but not getting how to handle the spaces before we start printing. Can you please give a basic idea of how can I print this whole pattern.
I am not able to get the logic of this question
Approach:
- In the given example, N=7 and the number of ROWS is 7.
- VERTICALLY, the pattern GROWS till ROW=N/2 and SHRINKS afterwards.
- ROW 1 has 4 ” “(SPACE) characters and then a value.
- The number of SPACE characters decreases whereas NUMERALS increase in count in each successive row.
- Also, note that the 1st value of the number placed in each row is the same as the number of the row.
- Also HORIZONTALLY the pattern has NUMERALS, then SPACES and NUMERALS afterwards.
Please check this code with comments and dry run it yourself you will get it https://ide.codingblocks.com/s/30137