Advertisement
JeffGrigg

Triangle Test

Nov 27th, 2018
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Triangle {
  4.  
  5.     static void staircase(int n) {
  6.         int j = 0;
  7.         for (int i = n; i >= 1; i--) {
  8.             for (j = 1; j <= i; j++) {
  9.                 System.out.print(" ");
  10.             }
  11.             for (int k = j; k <= n; k++) {
  12.                 System.out.print("#");
  13.             }
  14.             System.out.println();
  15.         }
  16.     }
  17.  
  18.     static Scanner scanner = new Scanner(System.in);
  19.  
  20.     public static void main(String[] args) {
  21.         int n = scanner.nextInt();
  22.         scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
  23.  
  24.         staircase(n);
  25.  
  26.         scanner.close();
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement