用*号打印直角三角形(正反)

 

 正直角三角形:

package com.Summer_0416.cn;

public class Test_Method08 {

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {//外层循环1,2,3,4,5
            for (int j = 0; j <=i; j++) {//内层循环1,2,3,4,5
                System.out.print("* ");
            }
            System.out.println();
        }

    }

}

反三角形:

package com.Summer_0416.cn;

public class Test_Method09 {

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {//外层 循环 1,2,3,4,5
            for (int j = 5; j > i; j--) {//内层循环5,4,3,2,1
                System.out.print("* ");
            }
            System.out.println();
        }

    }

}

 

posted @ 2019-04-16 21:29  Geek张东坡  阅读(1344)  评论(0编辑  收藏  举报