package nothh;

public class mmm {

    public static void main(String[] args) {

        
        //for循环内的 for按顺序运算,先打印1/4菱形,再打印上1/2菱形,左边空白处用空格代替,右边空白处无输入即可。
        for(int i = 0; i <= 4; i++)
        {
            for(int a = 4; a >= i; a--)
            {
                System.out.print(" ");
            }
            
            for(int b = 0;b <= i; b++)
            {
                System.out.print("*");
            }
            for(int c = 1; c <= i; c++)
            {
                System.out.print("*");
            }
            
            
            System.out.println( );
        }
        
        for(int i = 0; i <= 4; i++)
        {
            for(int a = 0; a <= i; a++)
            {
                System.out.print(" ");
            }
            
            for(int b = 4;b >= i; b--)
            {
                System.out.print("*");
            }
            for(int c = 4; c > i; c--)
            {
                System.out.print("*");
            }
            
            
            System.out.println( );
        }
        
    }

        
}

用for循环打印菱形

相关文章:

  • 2021-11-10
  • 2021-05-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
猜你喜欢
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案