On Oct 20, 2:18 am, "Mohammad" <(E-Mail Removed)> wrote:

> Dear Friends:

>

> I started learning c/c++ 2 weeks ago and so known a little about c++

> !!!

> now the problem is that, I found an excercise that I couldn't solve it

> in no ways !!!

>

> The problem is that:

>

> make this shape with 2 or 3 "for" Repetition Statement. (It means that

> it is possible even if with 2 !):

>

> **********

> ********

> ******

> ****

> **

> ****

> ******

> ****

> **

> ****

> ******

> ********

> **********

>

> I programmed one, but it isn't what I want ! but it's this:
<snip>

I just went ahead and did this myself. Basically, the easiest way to

do it is to look at the problem as three parts: the first (top)

triangle, the (middle) diamond, and the last (bottom) triangle. Write

three loops, one for each of the parts. Instead of using literal

values, use variables for the maximum width and the minimum width (you

can also use one for the starting width). Then you integrate the three

loops into one function. One easy way to have it switch to

decrementing and back to incrementing is to make a 'starsAdded'

variable that has a value of 2 (for putting on more stars), then

multiply it by -1 (for reducing the number of stars on the line).

There are tons of ways to do this. Mine is just one of them (and it's

not the most elegant of them, but whatever). I think it should be

possible to do it with just one for loop and some bools, but the code

might become a bit obfuscated. If you are still stumped after all the

advice you have gotten, just ask, and I will provide my answer to it.

I just didn't want to spoil the fun for you