Computer Science Canada Loop (continued) |
Author: | JWHooper [ Sun Feb 24, 2008 10:23 pm ] | ||||||
Post subject: | Loop (continued) | ||||||
I'm having a little difficulty on this one: Use nested loops that print the following pattern.
Here's what I did:
The result was:
I want to get the 2nd through the 6th row kinda moved to right, to make it look like the one above. I'm having a difficulty rewriting the code. Can anyone help, please? Thanks, J. |
Author: | OneOffDriveByPoster [ Mon Feb 25, 2008 1:06 am ] |
Post subject: | Re: Loop (continued) |
You can still print spaces to get want... |
Author: | md [ Tue Feb 26, 2008 11:09 am ] |
Post subject: | RE:Loop (continued) |
use setw perhaps? #include <iomanip> and then cout << setw(12) << n; The easiest way is probably to use string streams. The fastest and best way is probably to output spaces, how many spaces depends on the line. |