这个是我做的,我就知道这一种
- import java.util.Scanner;
- class SjxTest {
- public static void main(String[] args){
- System.out.println("请输入需要打印的等腰三角形的高");
- Scanner sc = new Scanner (System.in);
- int h = sc.nextInt();
- System.out.println("\n\n您要打印的三角形的高为:"+h);
- System.out.println("\n\n----------------输出结果------------\n\n");
- for(int i = 1;i<=h;i++){
- for(int j = 1;j<=h-i+20;j++ ){
- System.out.print(" ");}
- for(int z = 1;z<=i*2-1;z++){
- System.out.print("*");
- }
- System.out.print("\n");
- }
- }
- }
复制代码 |