borkins

13. Number Pyramid

Apr 12th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. /**
  2.  * Project: Advanced_Loops - created by borkins on 2017-04-09.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _13_NumberPyramid
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int n = Integer.parseInt(console.nextLine());
  14.    
  15.         for (int row = 0, k = 1; k <= n; row++)
  16.         {
  17.             for (int col = 0; col < row && k < n; col++, k++) {
  18.                 System.out.print(k + " ");
  19.             }
  20.             System.out.println(k++);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment