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



Home Answers Viewqa Java-Beginners Display patterns

Have Programming Question? Ask it here!
 
 
 


Shinichi
Display patterns
1 Answer(s)      a year and 5 months ago
Posted in : Java Beginners


Write a test program that read an integer n and call a method to display a pattern as follows: 1 2 1 3 2 1 4 3 2 1 ... n n-1 ... 3 2 1 The method header is public static void displayPattern(int n)


Advertisement
View Answers

November 22, 2012 at 3:54 PM


Here is a code that displays the following pattern:

1 
2 1
3 2 1
4 3 2 1
5 4 3 2 1

class Pattern{
     public static void displayPattern(int n){
        for(int i=1;i<=n;i++){

            for(int j=i;j>=1;j--){
            System.out.print(j);
            }
            System.out.println();
           }
     }
     public static void main(String args[]){
          displayPattern(5);       
    }
}


Related Tutorials/Questions & Answers:
Display patterns
Display patterns  Write a test program that read an integer n and call a method to display a pattern as follows: 1 2 1 3 2 1 4 3 2 1 ... n n-1 ... 3 2 1 The method header is public static void displayPattern(int n)   
Display patterns
Display patterns  Write a test program that read an integer n and call a method to display a pattern as follows: 1 2 1 3 2 1 4 3 2 1 ... n n-1 ... 3 2 1 The method header is public static void displayPattern(int n)  
Advertisements
Display Date and Time - Design concepts & design patterns
Display Date and Time  HI, Can u send me Html code displaying system date and time . Thanks Prakash  Hi Friend, Try the following code: System Date and Time var date = new Date(); document.write
patterns
patterns  who ever answered my previous ques thank u sooooo much!!!!!!!!!! though i was able to solve most complicated progms in java patterns are a night mare for me. thank u once again.can u help me on how to print
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Patterns
Patterns       Why Use Patterns?    They have been proven. Patterns reflect... used these patterns in their own work.     They are reusable
AJAX Patterns
AJAX Patterns       The publicly editable repository of all things Ajax. Design Patterns, Frameworks, Libraries, Tools and Links Read full Description
design patterns are used in Struts?
design patterns are used in Struts?  What design patterns are used in Struts
Design Patterns
Design Patterns       Design Patterns: Patterns are solutions for the specific problem in a specific context.  (OR) Patterns are solutions to recurring problem
J2EE design patterns - Design concepts & design patterns
J2EE design patterns  Hi all, could any one send me design patterns links. its very utgent. thanks, lakshminarayana.  Hi Friend, For J2EE Singleton Pattern,visit the following link: http
Design patterns - Design concepts & design patterns
Design patterns  I am new to design patterns and desigining . Please refer me some tutorial or pdfs of design patterns and desigining in easy language and understandable..so that i can apply it in my current project
Creational Patterns
Creational Patterns   This design category is all about the class instantiation. Creational pattern uses class-creation patterns and object-creational patterns. The class-creation pattern uses inheritance
Design patterns in ejb - EJB
Design patterns in ejb  Hi any any one send some links or material on design patterns in EJB iam toally new to this concept(i.e design patterns) ... of design patterns, strategies, and best practices for EJB design and development
Behavioral Patterns
Behavioral Patterns       Behavioral patterns are those patterns which are specifically... to avoid hard-coding and dependencies. The behavioral patterns are: 1. Chain
design patterns - Java Beginners
design patterns  what are the design patterns used in java?  Hi Friend, Please visit the following links: http://www.roseindia.net/designpattern/index.shtml http://www.roseindia.net/javatutorials/J2EE_singleton
Java: Patterns
Java: Patterns patternshare.org - A growing site of patterns... resource on patterns. Wikipedia provides a good starting point for patterns: Design pattern. http://wiki.java.net/bin/view/Javapedia/Patterns
About desing patterns - Struts
About desing patterns  How many Design Patterns are there supported by Java? and what is an Application Controller? what is the difference between Front Controller & Application Contorller?  Hi Friend, Please visit
Structural Patterns
Structural Patterns   Structural Patterns Structural Patterns describe how objects and classes can be combined to form larger structures. The difference between class patterns and object patterns
Relationship among Design patterns
Relationship among Design patterns       Patterns have relationships and work together... are with the different patterns, better you determine their interactions. Generally, to build
Categorizing Design Patterns
Categorizing Design Patterns       Patterns focus on different types of problems. Related patterns are grouped together and assigned a type. This helps programmers
Java - Design concepts & design patterns
Java  What are design patterens?  Hi friend, Software professionals may be familiar with the term "Design Patterns," but many have... not see the value and benefits design patterns bring to the software development
patterns printing using for loop in java
patterns printing using for loop in java  how to write the code for the pattern as: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
DAO,DTO,VO Design patterns
DAO,DTO,VO Design patterns  explain dao,dto,vo design patterns in strut 1.3?   Data Access Object (DAO) pattern is the most popular design patterns. It is used when you want to separate your presentation code from
PHP Design Patterns
PHP Design Patterns: A design pattern is like a template which guides us to solve a problem. Design patterns are not finished design that can be transformed directly into code. In Object Oriented based design patterns we can get
Display Problem
Display Problem  i am creating a small window application , i want to fetch data from ms-access(db) and want to display it on tables. what options are there to show result on table. is CSS helpfull
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
Display data
Display data  after successful login how i can fetch my account information from sql database
Display Tag
Display Tag  Hi Here is My code, There is problem At line no.3, where i want to display two fields in one column but it gives error.. Please any one knows the solution must reply Thanks In Advance
Display Information
Display Information  I have a listbox having many names and I have a button "display". I select some names and when I click the button , the names along with the address(they are in database) should be displayed. I am using php
image display
image display  sir the answer which you have sent to me is already I have I want to know that the syntax which you have writen for display... to display in image from databse plz help me i will wait for ur reply
Display Tag
Display Tag  Hi Here is My code, There is problem At line no.3, where i want to display two fields in one column but it gives error.. Please any one knows the solution must reply Thanks In Advance
display result
display result  i want a code that takes input from user through dropdown box and display the result into table.all the values regarding the user input must be displayed. i am using mysql database   hi i want study
Retina Display
Retina Display  is it possible to test Retina Display on simulator?   Yes, run the application from Xcode, when the simulator opens go to Hardware->Device->iPhone 4 That will now have a 2x screen resolution
profile display
profile display  Search page to display matching results in JSP and Servlet   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user-search.shtml
display shapes
display shapes  Hi, I would like to see geometric shapes like square, triangle, circle, rectangle as my outputs. Also, those figures shouldn't overlap while they get displayed. Please help me
image display
image display  sir the answer which you have sent to me is already I have I want to know that the syntax which you have writen for display... to display in "div image from databse /div" plz help me i will wait for ur reply
Display Configurations
Display Configurations   The year is 2136. A lot of things have changed but BITS Pilani still exists. The display technology used now is a WASDLED screen. This display technology consists of a configuration matrix containing
profile display
profile display  how to display matching Results using jsp-servlet?   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user-search.shtml http
profile display
profile display  how to display matching jobs in jobseeker's profile using jsp-servlets?   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user
javscript - Design concepts & design patterns
javscript  Dear sir, Thank you for ajax help.it is showing invalid coloumn name when am typing.Another thing sir,i want to display a text box by clicking on Addcc button and then display another text box by clicking on Addbcc
image display
image from access database but Sir I want that how I display image from database
 

 

 

DMCA.com