samedi 23 juillet 2016

java pattern ....code for the pattern

      1
  1   2   1
1  3    3   1

n lines

the logic i made

import java.io.*;
class pat {
    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n,p=0;
        System.out.println("Enter value of n");
        n=Integer .parseInt(in.readLine());

        for(int i=0;i<n;i++) 
        {
            for(int j=0;j<n-i;j++)
            {
                System.out.print(" ");
            }
            for(int k=0;k<=i;k++) 
            {
                System.out.print((int)Math.pow(11,p));
            }
            System.out.println(); 
            p++;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire