import java.util.Scanner; public class 打印空心金字塔 { public static void main(String[] args) { Scanner is_scanner=new Scanner(System.in); System.out.println("请输入行数:"); int hang=is_scanner.nextInt(); for(int diyi=1;diyi<=1;diyi++){ for(int kongge=1;kongge<=hang-1;kongge++){ System.out.print(" ");} System.out.println("*"); } for (int a = 2; a <= hang-1; a++) { for (int m = 1; m <= hang - a; m++) { System.out.print(" ");} for (int b = 1; b <= 1; b++) { System.out.print("*"); } for(int c=1;c<= 2*a-3 ;c++) { System.out.print(" " );} for (int n = 1; n <= 1; n++) { System.out.print("*"); } System.out.println(); } for(int wu=1;wu<=(2*hang)-1;wu++){ System.out.print("*"); } } }
java打印空心金字塔
最新推荐文章于 2023-03-21 21:37:48 发布