代码实现:打印三角形

/*
*
*** 
*****
*******
*****
*** 
* 
*/

public class Test19 {

	public static void main(String[] args) {
		for (int i = 1; i < 5; i++) {
			for (int j = 1; j <= 2*i-1; j++) {
				System.out.print("*");
			}
			System.out.println();
		}		
		for (int i = 5; i >= 1; i--) {
			for (int j = 1; j <= 2*i-1; j++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

 

posted on 2017-03-09 19:53  LoaderMan  阅读(494)  评论(0编辑  收藏  举报

导航