版权声明:对您有帮助的话,求您免费的关注和点赞 https://blog.csdn.net/weixin_42069140/article/details/89717097
问题描述
编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
* * * * *
* * * *
* * *
* *
*
时间限制:1.0s
内存限制:512.0MB
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for(int i = 0; i <n; i++) {
for(int j = 0; j < n - i; j++) {
System.out.print("* ");
}
System.out.println();
}
s.close();
}
}