Tuesday, November 20, 2012

Star Printing 2


 class Stars
    {
    public static void main(String[]args)
        {
             int m= 5;
             int s= m-1;
             int a;               
             for(int i = 0; i < m; i++)
                 {
                a = 2*i+1;
                for(int j = 1; j <= s+a; j++)
                {
                    if(j <= s)
                        System.out.print(' ');
                    else
                        System.out.print('*');
                }
                System.out.println();
                s--;
                 }
         
        }
    }

No comments: