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

  • 相关阅读:
    禁止鼠标多次点击选中div中的文字
    深入浅出 Nodejs 学习笔记 1
    svn 树冲突
    nodejs 按行读取 readline
    git版本控制器的基本使用
    规范javascript书写
    media query
    软件工程
    The sixth day
    The fifth day
  • 原文地址:https://www.cnblogs.com/smile-zcc/p/5554903.html
Copyright © 2011-2022 走看看