Ads

# recursion method

View Answers

October 17, 2008 at 11:43 AM

Hi friend,

Code for solving the problem :

public class RecursiveDiamond {

public RecursiveDiamond( int num ) {
int pre = num/2;
for (int i=1; i<=(num/2)+2; i+=2,pre-- ) {
line( pre, i );
}
for (int i=num; i>=(num/2)-2; i-=2,pre++ ) {
line( pre, i );
}
}
public void line( int pre, int stars ) {
for ( int i=0; i<pre; i++ )
System.out.print( " " );
for ( int i=0; i<stars; i++ )
System.out.print( "*" );
System.out.println( "" );
}
public static void main( String[] args ) {
new RecursiveDiamond( 7 );
}
}
Thanks

Ads

Related Tutorials/Questions & Answers:
recursion
recursion   Consider the following (recursive) static method and draw... this method is called with mystery("abc", 2, 0); b. Give the return value when this method is called with mystery("abcd", 3, 1
recursion program
recursion program  Hi this is my first java class, and i have been trying for hours to do this program. it is a recursion problem where the user will enter a continuous monthly investment, at a rate of 1% the program should say
Advertisements
ModuleNotFoundError: No module named 'recursion'
ModuleNotFoundError: No module named 'recursion'  Hi, My Python... 'recursion' How to remove the ModuleNotFoundError: No module named 'recursion' error? Thanks   Hi, In your python environment you
javascript recursion example
javascript recursion example   javascript recursion example   <html> <script> function factorial (n) { if(n==0) return(1); return (n * factorial (n-1) ); } document.write(factorial(5)); <
ModuleNotFoundError: No module named 'dongjun_recursion'
ModuleNotFoundError: No module named 'dongjun_recursion'  Hi, My... named 'dongjun_recursion' How to remove the ModuleNotFoundError: No module named 'dongjun_recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'hjc_recursion'
ModuleNotFoundError: No module named 'hjc_recursion'  Hi, My... 'hjc_recursion' How to remove the ModuleNotFoundError: No module named 'hjc_recursion' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My... named 'python-recursion' How to remove the ModuleNotFoundError: No module named 'python-recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Recursion-abhi'
ModuleNotFoundError: No module named 'Recursion-abhi'  Hi, My... named 'Recursion-abhi' How to remove the ModuleNotFoundError: No module named 'Recursion-abhi' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recursion-visualiser'
ModuleNotFoundError: No module named 'recursion-visualiser'  Hi...: No module named 'recursion-visualiser' How to remove the ModuleNotFoundError: No module named 'recursion-visualiser' error? Thanks   Hi
ModuleNotFoundError: No module named 'dongjun_recursion'
ModuleNotFoundError: No module named 'dongjun_recursion'  Hi, My... named 'dongjun_recursion' How to remove the ModuleNotFoundError: No module named 'dongjun_recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'hjc_recursion'
ModuleNotFoundError: No module named 'hjc_recursion'  Hi, My... 'hjc_recursion' How to remove the ModuleNotFoundError: No module named 'hjc_recursion' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My... named 'python-recursion' How to remove the ModuleNotFoundError: No module named 'python-recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My... named 'python-recursion' How to remove the ModuleNotFoundError: No module named 'python-recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My... named 'python-recursion' How to remove the ModuleNotFoundError: No module named 'python-recursion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'recursion-chintan'
ModuleNotFoundError: No module named 'recursion-chintan'  Hi, My... named 'recursion-chintan' How to remove the ModuleNotFoundError: No module named 'recursion-chintan' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'recursion-detect'
ModuleNotFoundError: No module named 'recursion-detect'  Hi, My... named 'recursion-detect' How to remove the ModuleNotFoundError: No module named 'recursion-detect' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'recursion_xxx'
ModuleNotFoundError: No module named 'recursion_xxx'  Hi, My... 'recursion_xxx' How to remove the ModuleNotFoundError: No module named 'recursion_xxx' error? Thanks   Hi, In your python
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
Calculate factorial Using Recursion
Calculate factorial Using Recursion  ... by using recursion in jsp. To make a program on factorial, firstly it must be clear what is recursion. In a simple language we can define recursion
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My... named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module named 'HS-recursion-List' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My... named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module named 'HS-recursion-List' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My... named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module named 'HS-recursion-List' error? Thanks   Hi, In your
method
method  can you tell me how to write an abstract method called ucapan() for B2 class class A2{ void hello(){ system.out.println("hello from A2"); }} class B2 extends A2{ void hello(){ system.out.println("hello from B2
XII STD RECURSION WITHOUT SCANNER
XII STD RECURSION WITHOUT SCANNER  the recursive function gives a stack overflow error. I want to calculate the GDC ie the greatest Integer function for two input numbers. the code of my program is as follows and the error comes
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion

Ads