输出等腰三角形
1 public class Three { 2 3 public static void main(String[] args) { 4 System.out.println("输入行高"); 5 Scanner input = new Scanner(System.in); 6 int n = input.nextInt(); 7 for (int i = 1; i <= n; i++) { 8 for (int k = n - i - 1; k >= 0; k--) { 9 System.out.print(" "); 10 } 11 for (int j = 1; j <= 2 * i - 1; j++) { 12 System.out.print(2 * i - 1); 13 } 14 15 System.out.println(); 16 } 17 18 }