题目:
编写方法显示如下图案:
public static void displayPattern(int n)
import java.util.Scanner; public class Exercise06_06 { public static void displayPattern(int n ){ String last =" "; for (int i =1;i<=n;i++){ for (int x =i;x<n;x++){ last += " "; } for (int y =i;y>=1;y--){ last += " "+y; } System.out.println(last); last=" "; } } public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); displayPattern(n); } }