问题描述
编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
* * * * *
* * * *
* * *
* *
*
提醒:星号和星号之间有空格,换行输出
import java.util.Scanner;
public class Main {
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();
}
}
}