zoukankan      html  css  js  c++  java
  • JAVA基础:求一个等腰三角形

    import java.util.Scanner;

    public class text {
     public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      System.out.println("请输入一个等腰三角形的高:");
      int height = scan.nextInt();
      for (int j = 1; j <= height; j++) {
       for (int i = 0; i < height - j; i++) {
        System.out.print("0");
       }
       for (int i = 0; i < (2 * j - 1); i++) {
        System.out.print("*");
       }
       System.out.println();
      }
     }
    }

    //求一个等边三角形的*

    import java.util.Scanner;

    public class P7 {
     public static void main(String[] args) {
      System.out.println("请输入一个三角形的高:");
      Scanner scanner=new Scanner(System.in);
      int number=scanner.nextInt();
      for(int i=1;i<number;i++){
       for(int space=1;space<=number-i-1;space++){
        System.out.print(" ");
       }
       for(int star=1;star<=i;star++){
        System.out.print("*"+" ");
       }
      System.out.println("");
     }
    }
    }

  • 相关阅读:
    汤姆大叔的博客
    ajax
    兼容谷歌的光标居中写法
    浅谈服务治理与微服务
    Java线程面试题合集(含答案)
    java设计模式之装饰者模式
    java集合类详解
    java线程-看这一篇就够了
    javaIO详解
    java反射详解
  • 原文地址:https://www.cnblogs.com/smile-zcc/p/5554903.html
Copyright © 2011-2022 走看看