HW4.17

时间:2023-03-09 23:09:12
HW4.17

HW4.17

HW4.17

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter the number of lines: ");
         int numberOfLines = input.nextInt();

         input.close();

         for(int i = 1; i <= numberOfLines; i++)
         {
             for(int j = numberOfLines - i; j > 0; j--)
                 System.out.print(" ");
             for(int j = i; j > 1; j--)
                 System.out.print(j);
             for(int j = 1; j <= i; j++)
                 System.out.print(j);
             System.out.println();
         }
     }
 }