package test2;
import java.io.IOException;
import java.util.Scanner;
public class arr1 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// 打印金字塔图案
System.out.println("请输入金字塔层数:");
Scanner input = new Scanner(System.in);
Scanner input2 = new Scanner(System.in);
System.out.println("请输入字符:");
int col = input.nextInt();
String a = input2.nextLine();
for (int i = 1; i <= col; i++) {// i表示行数
// 打印空格
for (int k = 0; k < col - i; k++) {
System.out.print(" ");
}
// 打印星星
for (int m = 0; m < 2 * i - 1; m++) {
System.out.print(a);
}
System.out.println();
}
}
}
效果图: