import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入行数:");
int row = scanner.nextInt();
if (row >= 3 && row <= 21) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < i; j++) {
System.out.print("");
}
for (int j = 0; j < 2 * (row - i) - 1; j++) {
System.out.print("*");
}
System.out.println();
}
} else {
System.out.println("非法行数");
}
}
}
学习用