v0mit

Untitled

Oct 10th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. public class NumberPyramid{
  2.     public static void printStuff(int iii, int nHeight)
  3.     {
  4.         for(int n = 0; n < (nHeight-iii); n++)
  5.         {
  6.             System.out.print(" ");
  7.         }
  8.  
  9.         for( int n = 1; n < iii; n++)
  10.         {
  11.             System.out.print(n);
  12.         }
  13.  
  14.         for(int n = iii; n > 0; n--)
  15.         {
  16.             System.out.print(n);
  17.         }
  18.     }
  19.  
  20.     public static void main(String[] args){
  21.  
  22.         int nHeight = Integer.parseInt(args[0]);
  23.  
  24.         for(int iii = 0; iii <= nHeight; iii++)
  25.         {
  26.             printStuff(iii, nHeight);            
  27.             System.out.print("\n");
  28.         }
  29.  
  30.         for(int iii = nHeight-1; iii >= 1; iii--)
  31.         {
  32.             printStuff(iii, nHeight);
  33.             System.out.print("\n");
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment