I understand, solving any problem can at times have one chasing round in circles and getting exhausted at the end. Hopefully you took a break and had some sleep. That usually helps.
Also I need to apologise, I may not have been thinking clearly myself yesterday. Some of the hints or suggestions I gave may have been wrong.
As for the latest code. Firstly, it looks over-complicated. Using a pair of nested
for
loops to output the stars seems more complexity than is needed. Just a single for loop should be enough.
While we're here. why are there six stars? Well, the nested loop does this:
star=1
star=2 *
star=3 **
star=4 *** |
that is, 1+2+3 = 6.
Enough of that. Just use one loop.
The second thought is, the number of stars printed on each line needs to be different each time, it depends on the line number (I see in the latest code, the line number is renamed as
int space
). The number of stars printed needs to be related to this, I suggest number of stars per line =
5 - space
.