蓝桥杯算法训练 图形显示

  • 问题描述
  • 编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
      * * * * *
      * * * *
      * * *
      * *
      *
      注意事项:图形*之间是有空格的。开始写程序没有空格,放进系统只得到50分,将程序加了空格之后,将程序copy进系统就是100分
      
import java.util.Scanner;

public class ALGO3_101 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = n;i>0;i--) {
            for(int j = i;j>0;j--) {
                System.out.print("*"+" ");

            }
            System.out.println();

        }
    }

}

猜你喜欢

转载自blog.csdn.net/weixin_41862755/article/details/79772557