recursion method

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









Related Tutorials/Questions & Answers:
recursion method - Ajax
recursion method  Can i ask for a program that input a lines in the diamond shape recursion method   Hi friend, Code for solving the problem : public class RecursiveDiamond { public RecursiveDiamond
recursion
recursion   Consider the following (recursive) static method and draw... this method is called with mystery("abc", 2, 0); (adsbygoogle = window.adsbygoogle || []).push({}); b. Give the return value when this method
Advertisements
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
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
Recursion - Java Beginners
Recursion  Create a method called, rangeMult, that uses recursion to multiply a range of array elements. The method takes the following arguments... of the range. Here is an example of how the method could be used: int
recursion numbers - Java Beginners
recursion numbers  I need to use recursion to test all values from 0 to 20 and see if they are contain in a 1-D array with values: 2,4,6,8,10,12,14,16,18,20. The results of all numbers from 0-20 will be printed
Recursion - Java Beginners
Recursion  HI!Can i ask for another recursion diamond,using recursive method and asking for how many lines should be inputed to create the diamond..., This is simple code of recursion code. public class RecursiveDemo { public static
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 '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-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-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-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 '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
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
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
Multiply a range of array elements using Recursion
Multiply a range of array elements using Recursion In this section you will learn how to use recursion to multiply a range of array elements. For this we have created a method rangeMult() that takes three arguments: an int array
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
java recursion
method inside the method??
method inside the method??  can't we declare a method inside a method in java?? for eg: public class One { public static void main(String[] args) { One obj=new One(); One.add(); private static void add
get method
get method   how to use get method: secure method is post method and most of use post method why use a get method
Method
Method       In this section, we will explore the concept of method in the reference of object oriented... and behaviors are defined by methods. Method : An brief introduction Methods
method question
method question  How do I figure out the difference in a method heading, a method body, and a method definition
Method Overloading
Method Overloading  In java can method be overloaded in different class
Method Overloading
Method Overloading  In java can method be overloaded in different class
A method getColumnCount.
A method getColumnCount.  There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set
abstract method
abstract method  is final method is in abstract class
Static method
Static method  what is a static method?   Have a look at the following link: Java Static Method
gc() method
gc() method  what is difference between java.lang.System class gc() method and java.lang.Runtime class gc() method
method name
method name  Is there any method which is equivalent to c++'s delay(int) function
main method
main method  Why is the java main method static
main method
main method  What is the argument type of a program's main() method

Ads