Here is a hint :
********** 10 stars
********* 9 stars
******** 8 stars
******* 7 stars
****** 6 stars
***** 5 stars
**** 4 stars
*** 3 stars
** 2 stars
* 1 stars
** 2 stars
*** 3 stars
****
*****
******
*******
********
*********
********** 10 stars
So you see that they decrease by 1 star until they reach 1 then they
start increment.
so assuming you can separate this problem into 2 blocks, you can
do something like this :
for(int i = 10; i != 1; i--)
printStars(i); //a function that prints i stars with endl
for(int i = 2; i <= 10; i++)
printStars(i);
Now what should your printStars look like :
for example if one calls printStars(4) it should output the following :
Go ahead and try to devise printStars then you problem becomes much
easier.
Reputation Points: 840
Solved Threads: 594
Senior Poster
Offline 3,865 posts
since Dec 2008