*
***
*****
*******
*********
*******
*****
***
*
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 2, 2012, 4:47 PM
ahmed samiPosted Nov 2, 2012, 5:29 PM
you are a Genius !!
thank you very much ..
^_^
VulpesPosted Nov 2, 2012, 5:14 PM
Each row will begin with (4 - row) spaces followed by (2 * row + 1) asterisks and a new line character
So:
row 0 -> 4 spaces + 1 asterisk + '\n'
row 2 -> 2 spaces + 5 asterisks + '\n'
row 3 -> 1 space + 7 asterisks + '\n'
row 4 -> 0 spaces + 9 asterisks + '\n'
This part of the code then prints the last 4 rows of the diamond:
Each row will begin with (row + 1) spaces followed by (7 - 2 * row) asterisks and a new line character.
So:
There are some fancier ways of doing this but this one is (fairly) easy to understand :)
ahmed samiPosted Nov 2, 2012, 5:02 PM
thank you ..
but can you explain the code please ?
couse i misunderstand it !!!