Saturday, August 20, 2011

Print the pattern


Print 1
         2 2
         3 3 3
import java.io.*;
class Pattren
{
  public static void main(String arg[ ])
  {
    BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    int n;
    try
    { 
       System.out.println("Enter the number of lines you want in your ouput: ");
       n=Integer.parseInt(in.readLine());
       for(int i=1;i<=n;i++)
         {
          for(int j=1;j<=i;j++)
           {
             System.out.print("  "+i);
           }
           System.out.println();
       }
     }
     catch(Exception e){ }
   }
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More