Preserved Topic: C++ help (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: my mother |
posted 02-01-2001 22:04
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 |
posted 02-01-2001 22:17
That would be a nested for loop: |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 02-01-2001 22:25
Thinking again I should tell you how it works. |
Maniac (V) Inmate From: soon to be "the land down under" |
posted 02-02-2001 00:48
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: |
posted 02-04-2001 09:57
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 |
posted 02-04-2001 10:57 |
Maniac (V) Mad Scientist From: |
posted 02-04-2001 13:41
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. |
posted 02-04-2001 18:37
You guys, |
Maniac (V) Inmate From: soon to be "the land down under" |
posted 02-04-2001 21:23
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. |
posted 02-04-2001 23:19
FYI, that's the way I learned it. |
Paranoid (IV) Inmate From: my mother |
posted 02-05-2001 00:03
thanks for the help guys |