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



Home Answers Viewqa Java-Beginners logic for pattern program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nishant Jain
logic for pattern program
5 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


what's the logic for create pattern program how can i create any pattern program with in minute. like this

123454321     *
1234 4321    ***
123   321   *****
12     21    ***
1       1     *

123321       1         1
12  21      1212      2323  
1    1     123123    345456
12  21    12341234  5678789
123321   1234512345

etc. i want know that how can i create this program in java without help whats the logic how can i understand that whoe's program code its make this type output


Advertisement
View Answers

February 24, 2011 at 1:17 PM


Java Pattern Example

 *
  * *
 * * *
  * *
   *
public class PatternExample {
public static void main(String[] args) {
int num=3;
int p = num;
int q = 0;
for (int i = 0; i <= num; i++) {
for (int j = p; j>= 1; j-- )
System.out.print(" ");
p-=1;
for (int k = 1; k <= i; k++)
System.out.print ("* ");
System.out.println();
}
num-=1;
for (int i = 0; i<=num; i++) {
for (int j = num; j > i; j--)
System.out.print (" *");
System.out.println();
for (int k = 0; k <= q; k++)
System.out.print(" ");
q+=1;
}
}
}


February 24, 2011 at 5:44 PM


Java Pattern Example:

123454321    
1234 4321    
123   321   
12     21    
1       1

public class PatternExample{
public static void main(String[] args){

int i,j,n=5;

for(i=0;i<=n;i++)
{
 System.out.println();
 for(j=1;j<=n-i;j++)
System.out.print(j);
 for(j=0;j<2*i;j++)
 System.out.print(" ");
 for(j=n-i;j>0;j--)
 System.out.print(j);
 }
}
}


July 25, 2011 at 11:00 PM


#include<stdio.h>
int main()
{
int i,j,n;
printf("Enter no");
scanf("%d",&n);
for(i=0;i<n;i++)
{
        for(j=1;j<=n-i;j++)
                printf("%d",j);
        for(j=0;j<((i*2)-1);j++)
                printf("*");
        for(j=n-i;j>0;j--)
        {
                if(j==n)
                {
                }
                else
                printf("%d",j);
        }
        printf("\n");
 }}


July 25, 2011 at 11:01 PM


#include<stdio.h>

int main()

{

int i,j,n;

printf("Enter no");

scanf("%d",&n);

for(i=0;i<n;i++)

{

        for(j=1;j<=n-i;j++)

                printf("%d",j);

        for(j=0;j<((i*2)-1);j++)

                printf("*");

        for(j=n-i;j>0;j--)

        {

                if(j==n)

                {

                }

                else



              printf("%d",j);


        }

        printf("\n");

 }}


November 2, 2012 at 1:06 PM


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

import java.io.*; class reversepattern { public static void main(String args[]) { int i,j; for(i=5;i>=1;i--) { for(j=1;j<=i;j++) { System.out.print(i); System.out.print(" "); } System.out.println(" "); } } }



Related Tutorials/Questions & Answers:
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
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
Advertisements
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
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
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
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
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
program displays a menu and asks the user to choose a pattern and size. But note...pattern  write a java program that can create four different patterns of different sizes. The size of each pattern is determined by the number
Pattern
Pattern  How to print this pattern in Java please help me A AC ACE ACEG ACEGI The program should be right to left
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
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
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
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
Java pattern
Java pattern  Write a Java program that outputs the following pattern. 1 21 321 4321 54321 654321
Logic Building
Logic Building  I wanted to devlop my logic ? How can i do so ? Can i start with java or i need to do c++ before
Logic and Degin
Logic and Degin  Need help in writing a pseudocode for this can so please help me with this just need to get started. In this lab, you are going... will be more efficient by using files and modularizing the program. This week, we
Logic Iterate.
Logic Iterate.  I have one doubt about logic:iterate. I use text feild inside of logic:iterate , there is possible will generate N no of rows (text feild) inside of iterate. my doubt is how to get the Paritcular rows text
Logic Iterate.
Logic Iterate.  logic iterate Struts I have one doubt about logic:iterate. I use text field inside of logic:iterate , there is possible... the Particular rows text value. for example: print("<logic:iterate id="xid
Logic and Design
Logic and Design  Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January
pattern printing
pattern printing  
Code for Pattern
Code for Pattern   1 23 345 5678 891011 Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
logic-iterate
logic-iterate  in my code i am using for-each loop for displaying data i want use tag to display data how to use plase help me <%@ page import="java.sql.*" %> <%String[] id = (String[])session.getAttribute("ids
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Advertisements
 

 

 

DMCA.com