Pattern

class Pattern1{
    public static void main(String ar[]){
        char []chrs={'a','b','c','d','e','f','g','h','i','j','k','l','m'};
        for(int i=0;i<chrs.length;i++){
            for(int j=0;j<2*chrs.length;j++){
                if(j<=i||(2*chrs.length-j)<=i+1){
                    System.out.print(chrs[i]);
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }
}

/* OUTPUT
a                        a
bb                      bb
ccc                    ccc
dddd                  dddd
eeeee                eeeee
ffffff              ffffff
ggggggg            ggggggg
hhhhhhhh          hhhhhhhh
iiiiiiiii        iiiiiiiii
jjjjjjjjjj      jjjjjjjjjj
kkkkkkkkkkk    kkkkkkkkkkk
llllllllllll  llllllllllll
mmmmmmmmmmmmmmmmmmmmmmmmmm

*/

No comments:

Popular Posts