Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NumberPyramid{
- public static void printStuff(int iii, int nHeight)
- {
- for(int n = 0; n < (nHeight-iii); n++)
- {
- System.out.print(" ");
- }
- for( int n = 1; n < iii; n++)
- {
- System.out.print(n);
- }
- for(int n = iii; n > 0; n--)
- {
- System.out.print(n);
- }
- }
- public static void main(String[] args){
- int nHeight = Integer.parseInt(args[0]);
- for(int iii = 0; iii <= nHeight; iii++)
- {
- printStuff(iii, nHeight);
- System.out.print("\n");
- }
- for(int iii = nHeight-1; iii >= 1; iii--)
- {
- printStuff(iii, nHeight);
- System.out.print("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment