本帖最后由 zxmzaofan 于 2010-11-03 15:23:43 编辑

解决方案 »

  1.   


    System.out.print("请输入行数(3-21):");
    Scanner input = new Scanner(System.in);
    int row = input.nextInt();
    if (row >=3 && row <=21) {
    for (int i = 0; i < row; i++) {
    for (int j = 0; j < i; j++) {
    System.out.print(" ");
    }
    for (int k = 0; k < (row-i)*2-1; k++) {
    System.out.print("*");
    }
    System.out.println();
    }
    } else {
    System.out.println("非法行数!");
    }