打印5行正三角形

时间:2021-05-25 09:07:23   收藏:0   阅读:21
public class TestDemo {
    public static void main(String[] args) {
        //打印三角形
        for (int i = 1; i <= 5; i++) {![](https://img2020.cnblogs.com/blog/2406104/202105/2406104-20210524230348648-800236161.png)


            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();
        }
    }
}

运行结果如下:
技术分享图片

原文:https://www.cnblogs.com/guoguodong/p/14806693.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!