Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax recursion method
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Randolph Jr
recursion method
1 Answer(s)      6 years and 3 months ago
Posted in : Ajax



Advertisement
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); b. Give the return value when this method is called with mystery("abcd", 3, 1
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
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
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
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)); <
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
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
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
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
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
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
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
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
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 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
method name
method name  Is there any method which is equivalent to c++'s delay(int) function
Advertisements
 

 

 

DMCA.com