1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 System.out.print("Enter an integer: "); 9 int number = input.nextInt(); 10 11 input.close(); 12 13 displayPattern(number); 14 } 15 16 public static void displayPattern(int n) 17 { 18 for(int i = 0; i < n; i++) 19 { 20 for(int j = 0; j < n - i; j++) 21 System.out.print(" "); 22 for(int j = i + 1; j > 0; j--) 23 System.out.print(j + " "); 24 System.out.println(); 25 } 26 } 27 }
时间: 2024-10-05 08:59:41