Advertisement
svetlyo0659

Untitled

Feb 19th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintTriangle2
  4.  
  5. {
  6.   public static void main(String[] args)
  7.   {
  8.     int n = 6;
  9.     char symbol = '*';
  10.  
  11.  
  12.     for (int row = n; row > 0; row--) {  // this loop makes 6 rows.
  13.  
  14.       for (int emptySpace = row; emptySpace < n; emptySpace++) { // this loop makes empty spaces for row 6 ,5 empty space and so on.
  15.         System.out.print(" ");
  16.       }
  17.       for (int col = 1; col <= row; col++) { // this loop makes the columns their are equal to the rows
  18.         System.out.print(symbol);
  19.       }
  20.  
  21.       System.out.println();
  22.     }
  23.   }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement