HW5.6

时间:2021-08-06 05:20:32

HW5.6

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         System.out.print("Enter an integer: ");
         int number = input.nextInt();

         input.close();

         displayPattern(number);
     }

     public static void displayPattern(int n)
     {
         for(int i = 0; i < n; i++)
         {
             for(int j = 0; j < n - i; j++)
                 System.out.print("  ");
             for(int j = i + 1; j > 0; j--)
                 System.out.print(j + " ");
             System.out.println();
         }
     }
 }

相关文章