import java.util.Scanner; public class Ch1_1_1 { public static void main(String[] args) { int i, j, k, n; Scanner input = new Scanner(System.in); System.out.print("请输入金字塔的层数"); n = input.nextInt(); for (i = 1; i <= n; i++) { for (j = 0; j <= i - 1; j++) { System.out.print(" "); } for (k = 1; k <= (2 * n - (2 * i - 1)); k++) { System.out.print("*"); } System.out.println(""); } } }