java实现打印正三角形

public class javaDemo {

    public static void main(String[] args) {

        for(int i = 0 ; i <= 5 ; i ++){
            for(int j = 5 - i ; j > 0 ; j --){
                System.out.print(" ");
            }
            
            for(int j = 1 ; j <= 2*i-1 ; j++){
                System.out.print("*");
            }
            
            System.out.println();
        }
        
        
    }

}
 

发布了40 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/sj_1993/article/details/103247154
今日推荐