import java.util.Scanner;
public class Demo1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个数");
int a = sc.nextInt();
for(int i = 0;i<a;i++){
for(int j=0;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
for(int i = a-2;i>=0;i--){
for(int j=0;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
亲测有效 |