java代码-----实现打印三角形

总结:今天我有个体会,喜欢不代表了解,了解不代表精通。我好失败

对于正三角形,就是注意空格、打星号。的实现。

package com.a.b;

public class Gl {

	public static void main(String[] args) {

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

		}

	}
}

  

原文地址:https://www.cnblogs.com/langlove/p/3519899.html