JAVA打印三角形
1 import java.util.*; 2 public class Xin { 3 public static void main(String[] args) { 4 Scanner sc = new Scanner(System.in); 5 int height = sc.nextInt(); 6 7 for(int i = 1;i < height+1;i++) { 8 for(int j = 1;j <= height-i;j++) { 9 System.out.print(" "); 10 } 11 for(int j = 1;j <= 2*i-1;j++) { 12 System.out.print("*"); 13 } 14 System.out.println(); 15 } 16 } 17 }