java_2018_Day18_绘制一个菱形

public static void cx3(int a){                        //绘制一个◇菱形
        for(int x = 1;x<=a;x++){
            for(int a1 = 1;a1<=a-x;a1++){
                System.out.print("  ");
            }
            for(int a2 = 1;a2<=2*x-1;a2++){
                if(a2==1 || a2==2*x-1){
                    System.out.print("★");
                }else{
                    System.out.print("☆");
                }
            }
            System.out.println();
        }
        for(int x = 1;x<=a;x++){
            for(int a1 = 1;a1<=x;a1++){
                System.out.print("  ");
            }
            for(int a2 = 1;a2<=2*(a-x-1)+1;a2++){
                if(a2==1 || a2==2*(a-x-1)+1){
                    System.out.print("★");
                }else{
                    System.out.print("☆");
                }
            }
            System.out.println();
        }
        
        
    }

猜你喜欢

转载自www.cnblogs.com/dlbm/p/9199137.html