I am working on writing a simple program to make designs out of asterisks. I am having a lot of trouble coming up with the code to make this design though ( the underscores represent spaces from the left-most edge of the page):
*
**
_*
****
__*
__**
___*
********
____ *
____ **
_____ *
____ ****
_______*
_______**
________*
The method to make this design should be recursive, with a single parameter, n (the number of stars in the longest line). I supposed there could be a second parameter that could control the number of spaces the stars are moved over. The code should work for any number, but I think it looks better with simple numbers (2, 4, 8, 16, etc).
Any ideas are greatly appreciated!
Recursion
Started by jendana89, Apr 13 2010 02:45 PM
3 replies to this topic
#1
Posted 13 April 2010 - 02:45 PM
|
|
|
#2
Posted 17 April 2010 - 03:43 AM
Actually I can't see the figure you are trying to print. Can you post a screenshot?
#3
Posted 25 April 2010 - 12:47 AM
i think that there is a constant pattern that do not need to be changed you will only increase the spaces that you will use
*
**
_*
****
__*
__**
___*
as this pattern is repeated in the part you posted twice only with more spaces but i cant figure out how the spaces are increasing, if you can post a more accurate example i think we may be able to help more.
*
**
_*
****
__*
__**
___*
as this pattern is repeated in the part you posted twice only with more spaces but i cant figure out how the spaces are increasing, if you can post a more accurate example i think we may be able to help more.
"Recursion is just a line of code"
-Karim Hosny-
My flickr
-Karim Hosny-
My flickr
#4
Posted 25 April 2010 - 05:37 PM
What patter are you attempting to display. You mention that simple numbers look better but what dictates how those numbers are used?


Sign In
Create Account

Back to top









