![]() Preserved Topic: C++ help (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: my mother |
![]() I am just starting to learn C++, and I'd like to know how to make a program using for loops that asks for a number, and then outputs X's in a triangle thing. For example, if a user inputs 5, I want it to look like this: |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
![]() That would be a nested for loop: |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
![]() Thinking again I should tell you how it works. |
Maniac (V) Inmate From: soon to be "the land down under" |
![]() Well, warmage gave a really good explanation so I don't have much to say. Here's the code in c++ : |
Paranoid (IV) Inmate From: |
![]() I don't think it's any point to use recursion, or maybe I am not smart enough to come up with a good recursion that can be shorter then a for loop. |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
![]() |
Maniac (V) Mad Scientist From: |
![]() Ahh... recursion. The Nemesis has returned! I have seen too many people lock-up because they don't understand recursioin. Used to happen *all* the time in my Pascal class when we were learning about nodes. |
Bipolar (III) Inmate From: where the snow falls like rain. |
![]() You guys, |
Maniac (V) Inmate From: soon to be "the land down under" |
![]() Yeah, setw() will probably do the job, but if you're just learning, do it the hard way so that you can really learn your for loops. |
Bipolar (III) Inmate From: where the snow falls like rain. |
![]() FYI, that's the way I learned it. |
Paranoid (IV) Inmate From: my mother |
![]() thanks for the help guys |