题解 | #金字塔图案#
金字塔图案
http://www.nowcoder.com/practice/d84e8339f9444bb6b29bd3f227c8e538
import java.util.Scanner;
import java.util.Collections;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNextInt()) {
int num = scan.nextInt();
for(int i = 1; i <= num; i++) {
System.out.println(String.join("", Collections.nCopies(num - i, " ")) +
String.join("", Collections.nCopies(i, "* ")));
}
}
}
}