HELP

Hi guys / girls,

I'm trying to write code that prints the following :

******7
*****7*
****7**
***7***
**7****
*7*****
7******

Any ideas?

I know I will be using for loops. So far this is what I have.


void PrintRD(int RD)
{
for(int row = 0; row <= RD; row++){
cout << RD;
cout << endl;
for(int col = 0; col <= RD; col++)
cout << "*";
}

}


OUTPUT
Enter an integer for the dimension: 7

7
********7
********7
********7
********7
********7
********7
********7
********



Last edited on
You're off to a start. Obviously, not exactly where you wanted to go, but a start.

Think along these lines:

In the first row, for any RD, there should be RD starts and then the RD numeric output, but no following stars.

On the second row, there should be RD - 1 stars, then the numeric output, then one star.

Then, RD - 2 stars, the number, then two stars.

Then, RD - 3 stars, the number, then three stars.

Think about that pattern, notice the implied loop (1, 2, 3....), and how I stated the method.

See if you can fashion the loops.

Note, too, you have an outer loop, then an inner loop. Think about stars, number, stars....it implies more than one interior loop where the numeric output is between them (and the first one loops zero times).
Topic archived. No new replies allowed.