JAVA编程

public static void main(String[] args) {
  System.out.println("输入三角形的行数");
  Scanner scanner = new Scanner(System.in);
  int n = scanner.nextInt();
  for (int i = 0; i < n; i++) {
    for (int x = i + 1; x < n; x++) {
      System.out.print(" ");
  }
   for (int y = 0; y < (i + 1) * 2 - 1; y++) {
      System.out.print("*");
  }
      System.out.print(' ');
  }
}

原文地址:https://www.cnblogs.com/AllenIverson/p/4488757.html