Wednesday, January 8, 2014


patterns using java:-

1>

import java.io.*;
class pattern
{
    public static void main()throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String a = br.readLine();
        int x = Integer.parseInt(a);
       
        for(int i=1 ; i<=x ; i++)
        {
            for(int j=1 ; j<=i ; j++)
            {
                System.out.print("1");
            }
            System.out.println();
        }
    }
}

2>

import java.io.*;
class pattern2
{
    public static void main()throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String a = br.readLine();
        int x = Integer.parseInt(a);
       
        for(int i=1 ; i<=x ; i++)
        {
            for(int j=1 ; j<=i ; j++)
            {
                System.out.print(j);
            }
            System.out.println();
        }
    }
}

3>

import java.io.*;
class pattern3
{
    public static void main()throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String a = br.readLine();
        int x = Integer.parseInt(a);
       
        for(int i=1 ; i<=x ; i++)
        {
            for(int j=1 ; j<=i ; j++)
            {
                System.out.print(i);
            }
            System.out.println();
        }
    }
}

4>

import java.io.*;
class pattern4
{
    public static void main() throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String s = br.readLine();
        int x = Integer.parseInt(s);
       
        for(int i=x ; i>=0 ; i--)
        {
            for(int j=1 ; j<=i ; j++)
            {
                System.out.print(j);
            }
            System.out.println();
        }
    }
}

5>

import java.io.*;
class pattern5
{
    public static void main() throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String s = br.readLine();
        int x = Integer.parseInt(s);
       
        for(int i=x ; i>=0 ; i--)
        {
            for(int j=1 ; j<=i ; j++)
            {
                System.out.print(i);
            }
            System.out.println();
        }
    }
}

6>

import java.io.*;
class pattern6
{
    public static void main() throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
       
        System.out.println("enter limit");
        String s = br.readLine();
        int x = Integer.parseInt(s);
       
        for(int i=1 ; i<=x ; i++)
        {
            for(int j=1; j<=x ; j++)
            {
                System.out.print(i);
            }
            System.out.println();
        }
    }
}
           
       
        

No comments:

Post a Comment