- package day05;
- import java.util.Scanner;
- public class SanJianXing {
- /**
- * 等腰三角形
- *
- * @param args
- */
- public static void main(String[] args) {
- while (true) {
- System.out.println("请输入正三角形的长度:");
- getZhengSanJiaoXing();
- }
- }
- private static void getZhengSanJiaoXing() {
-
-
- Scanner input = new Scanner(System.in);
- int count = input.nextInt();//将输入的长度赋值给count变量
- for (int i = 1; i <= count; i++) {//控制行数
- for (int x = 1; x <= count - i; x++) {//x控制空格
- System.out.print(" ");
- }
- for (int k = 1; k <= i; k++) {
- System.out.print("*" + " ");
- }
- System.out.println();
- }
- }
- }
复制代码
|
|