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 9 System.out.print("Enter the number of lines: "); 10 int numberOfLines = input.nextInt(); 11 12 input.close(); 13 14 for(int i = 1; i <= numberOfLines; i++) 15 { 16 for(int j = numberOfLines - i; j > 0; j--) 17 System.out.print(" "); 18 for(int j = i; j > 1; j--) 19 System.out.print(j); 20 for(int j = 1; j <= i; j++) 21 System.out.print(j); 22 System.out.println(); 23 } 24 } 25 }
时间: 2024-10-30 16:51:27