package week4; import java.util.Scanner; public class task1 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of rows: "); int rows = scanner.nextInt(); for (int i = rows; i >= 1; i--) { for (int j = 1; j <= i; j++) { System.out.println("*"); } int spaces = (rows - i) * 2 - 1; if (spaces > 0) { for (int j =1; j <= spaces; j++) { System.out.println(" "); } } if (i < rows) { for (int j = 1; j <= i; j++) { System.out.println("*"); } else { for (int j = 1; j < i; j++) { System.out.println("*"); } } } } System.out.println(); } scanner.close(); }