题解 | #翻转金字塔图案#
翻转金字塔图案
https://www.nowcoder.com/practice/c4775776e4464537bfb6a5ba37c596c6
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
while(sc.hasNextInt()){
n = sc.nextInt();
StringBuffer str = new StringBuffer();
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(j >= i){
str.append("* ");
} else {
str.append(" ");
}
}
str.append("\n");
}
System.out.print(str.toString());
}
}
}
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
while(sc.hasNextInt()){
n = sc.nextInt();
StringBuffer str = new StringBuffer();
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(j >= i){
str.append("* ");
} else {
str.append(" ");
}
}
str.append("\n");
}
System.out.print(str.toString());
}
}
}