显示图案 Exercise06_06

 1 import java.util.Scanner;
 2 /**
 3  * @author 冰樱梦
 4  * 时间:2018年下半年
 5  * 题目:显示图案
 6  * 输入一个数
 7 5
 8         1 
 9       2 1 
10     3 2 1 
11   4 3 2 1 
12 5 4 3 2 1 
13 
14  *
15  */
16 public class Exercise06_06 {
17     public static void main(String[] args){
18         Scanner input = new Scanner(System.in);
19         System.out.println("输入一个数");
20         int n=input.nextInt();
21         displayPattern(n);
22     }
23     public static void displayPattern(int n){
24         for(int i=1;i<=n;i++){
25             for(int q=i;q<n;q++)
26                 System.out.print("  ");
27             for(int j=i;j>=1;j--){
28                 System.out.print(j+" ");
29             }
30             System.out.print("\n");
31         }
32     }
33 }

 

posted @ 2018-12-25 14:30  CHERRYL  阅读(161)  评论(0编辑  收藏  举报