Friday, October 21, 2011

Pattern Pyramid

//Program to pyramid of numbers
import java.io.*;
public class pattern_pyramid
{
    public static void main (String [] args) throws IOException
    {   int space=8;int j=0;           
        for(int i=1;i<=7;i++)          
        {
            for(int sp=1;sp<=space;sp++)
            {
                System.out.print(" ");  
            }
            for(j=1;j<=i;j++)        
            {
                System.out.print(j);   
            }
            for(int k=j-2;k>=1;k--) 
            {
                System.out.print(k);    
            }
            System.out.println();       
            space--;            
        }   
    }
}

No comments:

Post a Comment