首页 > 其他 > 详细

三角形

时间:2020-05-30 00:44:14      阅读:38      评论:0      收藏:0      [点我收藏+]

等腰三角形:

package com.steven.demo;

/**
 * 打印 5行的三角形
 */
public class SquareDemo {
    public static void main(String[] args) {

        for (int i = 1; i < 6; 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();
        }
    }
}

直角三角形:

package com.steven.demo;

/**
 * 打印 5行的三角形
 */
public class SquareDemo {
    public static void main(String[] args) {

        for (int i = 1; i < 6; 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();
        }
    }
}

 

三角形

原文:https://www.cnblogs.com/stevenx/p/12990147.html

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