Share on Google+Share on Google+

Randolph Jr
recursion method
1 Answer(s)      8 years ago
Posted in : Ajax

Ads

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
Tutorials   
Java Spring Hibernate Struts Training Ajax java How to cascade two text boxes?? How to create runtime drag and drop form builder using asp.net mvc and jquery jsp+ajax validation JQuery-JSP AJAX example not working What is Ajax Framework How to write first example in Ajax? What are Advantages and Disadvantages of AJAX What is Ajax? how to set running watch with descending order in applycation with ajax how to set running watch with descending order in applycation with ajax jsp pages for dispatchaction for adding user to database c++ new, delete, string class using ajax i want to insert data into oracle database how to generate reports from oracle database using jsp and ajax code dynamic creation of multiple drop-down menus Ajax programming tutorials Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page What is Java? How to make a ajax application which take data from textarea and that page is not refreshing. how can add new line character into ajax response for java how can add new line character into ajax response for java c# c# asp.net Struts 2 + Ajax bodygaurd java Ajax mew 333 data insertion and fetch 1 my answer what is an ajax call? what is an ajax call? JSF How to easily send and receive recorders from database (in AJAX)? calculating time difference for manually entered in-time and out-time in hours and min for dynamically generated rows in jsp and display in third textfield. how to operate on select box using ajax in struts2? how to operate on select box using ajax in struts2? Auto Search box using ajax Dependant Dropdown Lists AJAX REGISTRATION FORM ajax code for jsp java i want to know how a slide will hide i want to know how a slide will hide

Ads

 
Advertisement null

Ads