/*
* 打印等腰三角形,打印的行数由用户输入,打印完后,由用户选择继续打印还是退出程序。
* 课本54页的第二题
* EquicruralTriangle.java
* @author LGM
* @version 2015.04.01
*/
import java.util.Scanner;
public class EquicruralTriangle {
public static void main(String[] args) {
int HowMany = 0; //定义需打印行数
String Chooes = "y"; //定义打印完后,是否继续
Scanner input = new Scanner(System.in); //定义用户可输入
while (Chooes.equals("y")) { //如果是“y”,继续打印
System.out.println("请问你需要打印多少行等腰三角形:");
HowMany = input.nextInt(); //接收打印的行数
for (int i = 1; i <= HowMany; i++) {
for (int k = 1; k <= HowMany - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("是否继续打印,继续请输入y;退出请随意输入!");
Chooes = input.next();
}
System.out.println("再见!欢迎再次使用!");
}
}