For 循环各种*号

2017-10-27 22:41:00

For 循环各种*号

  *****
  ****
  ***
  **
  *
    

    {
        int zz = 5;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < zz; j++) {
                System.out.print("*");
            }
            System.out.println();
            zz--;
        }
    }
    {
        int zz = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = zz; j < 5; j++) {
                System.out.print("*");
            }
            System.out.println();
            zz++;
        }
    }
    {
        for (int i = 0; i < 5; i++) {
            for (int j = i; j < 5; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

  *
  **
  ***
  ****
  *****

    {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

  * * * * *
   * * * *
    * * *
     * *
      *

{

        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j < i; j++) {
                System.out.print(" ");
            }
            for (int k = i; k <= 5; k++) {
                System.out.print("* ");
            }
            System.out.println();
        }
    }

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »