首页 > 其他 > 详细

打印三角形

时间:2021-05-12 14:47:26      阅读:25      评论:0      收藏:0      [点我收藏+]

打印三角形

package com.luo.struct;

public class Demo1 {
    public static void main(String[] args) {
        //打印三角形 5行
        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();
        }
        //打印正方形 5行
        for (int f = 1; f <= 25; f++) {
            System.out.print("*"+"  ");
            if(f%5==0){
                System.out.println();
            }
        }

    }


}

技术分享图片

打印三角形

原文:https://www.cnblogs.com/nanxiong/p/14758685.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!