Tuesday, January 5, 2016

Pattern-22

/**
Pattern-22:
Enter N : 5
$#$#$
$#$#
$#$
$#
$
*/

import java.io.*;

public class Pattern22
{
 public static void main(String args[])throws IOException
 {
     int i, j, n;
     InputStreamReader read = new InputStreamReader(System.in);
     BufferedReader in = new BufferedReader(read);

     System.out.print("Enter N : ");
     n=Integer.parseInt(in.readLine());

     for(i=1;i<=n;i++)
     {
         for(j=n;j>=i;j--)
         {
             if(j%2==1)
                System.out.print("$");
             else
                System.out.print("#");
         }
         System.out.println();
     }
 }
}

No comments:

Post a Comment