算法训练 图形显示

    xiaoxiao2021-12-14  38

      算法训练 图形显示   时间限制:1.0s   内存限制:512.0MB      问题描述   编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):   * * * * *   * * * *   * * *   * *   *

    import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for(int i=0;i<n;i++){ for(int j=n-i;j>0;j--){ if(j == 1) System.out.print("*"); else System.out.print("* "); } System.out.println(); } } }

    转载请注明原文地址: https://ju.6miu.com/read-969971.html

    最新回复(0)