我是靠谱客的博主 闪闪纸飞机,这篇文章主要介绍java实现打印三角形,现在分享给大家,希望可以做个参考。

/*
 * 	三角形小练习2
 * */
	public static void print0(int Row){
		for(int row=0;row<Row;row++){
			int col=0;
			for(col=0;col<Row+1-row;col++){
				System.out.print(" ");
			}
			for(col=Row+1-row;col<=Row+1+row;col++){
				System.out.print("*");
			}
			System.out.println();
		}
	}

【结果:】

0                    *                  

1                   ***                 

2                  *****                

3                 *******               

4                *********              

5               ***********              

6              *************            

7             ***************           

8            *****************          

9           *******************         

10          *********************        

11         ***********************       

12        *************************      

13       ***************************     

14      *****************************    

15     *******************************   

16    *********************************  

17   *********************************** 

18   *************************************

19  ***************************************

最后

以上就是闪闪纸飞机最近收集整理的关于java实现打印三角形的全部内容,更多相关java实现打印三角形内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(69)

评论列表共有 0 条评论

立即
投稿
返回
顶部