I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

s.sharma\′s Photo
4 Dec 07, 4:47PM
Hey, I see your problem. Have you considered first writing each line of your triangle to a std::list of string. As you do you can note the lenght of the longest line, and then go back to the top of the list and output appropriate spaces to center everything.

Can't see how you can predict the necessary spacing to insert on the left side, until you've calculated each row of the triangle. Obviously the number of row and the size of the numbers within each row will impact the spacing need on the rows above.
Currently you need to be logged in to leave a message.