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



Home Answers Viewqa Java-Beginners what's the logic for create pattern program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shalini
what's the logic for create pattern program
1 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

April 2, 2012 at 3:31 PM


public class Pattern {
        public static void main(String[] args) {
                int[] array = {1,2,3,4,5};
                System.out.println("Original array is:");
                printArray(array);
                for(int i=1;i<=4;i++){
                shift(array, 1);
                        printArray(array);
                }
        }

        public static void shift(int[] array, int amount) {
                for (int j = 0; j < amount; j++) {
                        int a = array[array.length - 1];
                        int i;
                        for (i = array.length - 1; i > 0; i--)
                                array[i] = array[i - 1];
                        array[i] = a;
                }
        }

        public static void printArray(int[] array) {
                for (int x = 0; x < array.length; x++) {
                        System.out.print(array[x] + " ");
                }
                System.out.println();
        }

}


Related Tutorials/Questions & Answers:
what's the logic for create pattern program
what's the logic for create pattern program   1 2 3 4 5 5 1 2 3 4 4 5 1 2 3 3 4 5 1 2 2 3 4 5 1
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
Advertisements
logic for pattern program
logic for pattern program  what's the logic for create pattern program how can i create any pattern program with in minute. like this 123454321... create this program in java without help whats the logic how can i understand
pattern program
pattern program  can some one plz help me to wright the logic for the following pattern abcdcba abc cba ab ba a a ab ba abc cba abcdcba
What is programming logic ?
What is programming logic ?  What is programming logic
pattern program
pattern program  13579 1357 135 13 1 pattern program in java   Here is your Example:- package Compare; public class PatternDemo { public static void main(String [] args){ int c=10; for(int i=0;i<
pattern program
pattern program  can any 1 print the following pattern in java .plz give the code.and yes thank u so much for answering my 2 other questions.had i... before.anyways the pattern goes like this abcdcba abc cba ab ba a a ab ba abc abc
What is static factory pattern?
What is static factory pattern?  Hello, please tell me what is static factory pattern? Thank you..   Dear friend, you can go through the following links to better understand the static factory pattern - Factory
Moire Pattern Java Program
Moire Pattern Java Program  **strong text**What you are seeing in the screenshot are two sets of concentric circles. The centers of the circles... an oval whose width and height are the same. Make the program from this older code
What is an efficient way to implement a singleton pattern in Java?
What is an efficient way to implement a singleton pattern in Java?  What is an efficient way to implement a singleton pattern in Java
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
pattern
pattern  write a java program that can create four different patterns of different sizes. The size of each pattern is determined by the number... program displays a menu and asks the user to choose a pattern and size. But note
Pattern
Pattern  How to print this pattern in Java please help me A AC ACE ACEG ACEGI The program should be right to left
program to create nested tables
program to create nested tables  program to create nested tables
What is the syntax for a CREATE TABLE statement?
What is the syntax for a CREATE TABLE statement?  What is the syntax for a CREATE TABLE statement
Java create triangle pattern
Java create triangle pattern In this tutorial, you will learn how to create...(); System.out.print("what is the symbol you want to use: "); symbol= read.next().charAt(0...); } } } Output: how many lines you want to print? 5 what is the symbol you want
Pleae help me to give logic and code for this program - Java Beginners
Pleae help me to give logic and code for this program  Write a function that given the string ?original? create a new string ?dramatic? that has two consecutive copies of each letter from the original string. For example
pattern
pattern  1 3 1 5 3 1 7 5 3 1 9 7 5 3   Here is a number pattern example. 1 3 1 5 3 1 7 5 3 1 9 7 5 3 1 class Pattern{ public static void main(String args[]){ for(int i=1;i<=9;i
program to create node.
program to create node.  Hi i'm new to flex and trying to create a node and it should also have an option of right click wit any properties. how do i do this. Also i need to create a gui having drag and dop options. Please help
Pattern
Pattern  1234321 123 321 12 21 1 1 please,give me this pattern in java   class Sixth_1 { public static void main(String args...; } } }   Here is a number pattern class Pattern{ public
write a program to create a user defined
write a program to create a user defined   plz send me code   Hi Friend, Please specify what do you want to create? Thanks
create a jsp program
create a jsp program  please help , create web Application using jsp and jdbc which tacking your name,id and DOB .On clicking to submit Button it stores the information into the database and Displays alll the records
what is wrong in this program......
what is wrong in this program......  program to implement given inheritance import java.io.*; class Student { int rno; String name; DataInputStream ob = new DataInputStream(System.in); void getRoll
html program to create home page
html program to create home page  html program to create home page
what is wrong with this program
what is wrong with this program  import java.io.*; class Distance { int feet,inch; void read() { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine()); inch
what is wrong in this program
what is wrong in this program  import java.io.*; class Distance { int feet; int inch; void read(int feet, int inch) { System.out.println("Enter distance in feet and inches "); feet=Integer.parseInt(ob.readLine
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
Advertisements
 

 

 

DMCA.com