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("");
     }
    }
    }

  • 相关阅读:
    日常巡检
    mysql 主从
    tomcat +apache 动静分离
    ELK安装
    LVS-NAT模式
    shell 三剑客
    shell $传参
    zabbix安装
    lvs-DR 负载均衡
    解决ubuntu中pycharm的图标没有问题
  • 原文地址:https://www.cnblogs.com/smile-zcc/p/5554903.html
Copyright © 2011-2022 走看看