Well, after a quick glance at the code you're iterating N times but only printing N-1 times. When counter == peak the loop does nothing so you'd get something like:

chosen=5
for(int counter = 0; counter < chosen ; ++counter){ // note +1 removed }

counter = 0, 1, 2, [3]NO_PRINT, 4
  *0
 ***1
*****2
 ***4

(note: my ascii art, I assume this is what the code would produce...)
Now add the +1
for(int counter = 0; counter < chosen +1 ; ++counter){
0, 1, 2, [3]skip, 4, 5
  *0
 ***1
*****2
 ***4
  *5

With your implementation as it stands you need to skip iteration N/2+1 to get the correct output. But you still need to write N lines.

Hope that makes sense...!! :D
Stewart

Reply via email to