Que
02-17-2009, 09:12 PM
I'm trying to get some recursion experience but having trouble starting up.
I want to print the following:
*
**
* //one space
****
*//3 spaces
**//3 spaces
*//4 spaces
******** //max stars printed here
*//5 spaces
**//5 spaces
*//6 spaces
****//5spaces
*//7 spaces
**//7 spaces
*//8 spaces
I apologize if my indentation is off slightly but I have left in comments as to how many spaces there should be before a * is printed.
The method gets passed along 2 ints, an indentation and a number that prints the max number of stars in the middle. The above output is made when you pass the method (0, 8).
Trouble is, I am not sure how to start the recursive call. I know i can split this problem into 3 parts, Top, Middle and Bottom.
Middle doesn't look like a problem, a simple for loop to print that # of stars.
But I am kind of confused as to how I should start this off so it prints the top part, let alone how to print the bottom. Any help is appreciated.
I want to print the following:
*
**
* //one space
****
*//3 spaces
**//3 spaces
*//4 spaces
******** //max stars printed here
*//5 spaces
**//5 spaces
*//6 spaces
****//5spaces
*//7 spaces
**//7 spaces
*//8 spaces
I apologize if my indentation is off slightly but I have left in comments as to how many spaces there should be before a * is printed.
The method gets passed along 2 ints, an indentation and a number that prints the max number of stars in the middle. The above output is made when you pass the method (0, 8).
Trouble is, I am not sure how to start the recursive call. I know i can split this problem into 3 parts, Top, Middle and Bottom.
Middle doesn't look like a problem, a simple for loop to print that # of stars.
But I am kind of confused as to how I should start this off so it prints the top part, let alone how to print the bottom. Any help is appreciated.