五行三角形

源码:

public static void main(String[] args) {
        for (int i = 1; i < 5; i++){
            for (int j = 5; j >= i; j--){
                System.out.print(" ");
            }
            for (int j = 1; j <= i; j++){
                System.out.print("*");
            }
            for (int j = 1; j < i; j++){
                System.out.print("*");
            }
            System.out.println();
        }
    }

输出结果:

/**
 *      *
 *     ***
 *    *****
 *   *******
 */
posted @ 2021-10-17 15:30  王铁柱yyds  阅读(62)  评论(0)    收藏  举报