* ************ ************ *
** *********** *********** **
*** ********** ********** ***
**** ********* ********* ****
***** ******** ******** *****
****** ******* ******* ******
******* ****** ****** *******
******** ***** ***** ********
********* **** **** *********
********** *** *** **********
*********** ** ** ***********
************ * * ************ |
What you have so far generates something like this:
*.....
**.....
***.....
****.....
*****..... |
For the sake of clarity, I replaced space by a dot.
Try this:
1 2 3 4 5 6 7 8 9 10 11
|
for (i=1; i<=n; i++)
{
// 1a
for(j=i; j; j--)
cout<<"*";
// 1b
for(j=n-i+1; j; j--)
cout<<".";
cout<<endl;
}
|
I labelled the code 1a and 1b, as this is the first of four main sections of the image.
Concentrate now on part 2a and 2b.
After that, the second half is a mirror-image of the first, so the code can be more or less cut and pasted for that.
Hope this helps.
Last edited on