package xiaofei.bank.com;
import java.util.Scanner;
public class MaiClass {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int len = s.nextInt();
for (int i = 0; i <= len; i++) {
if (i<=(len/2)) {
for (int j = 0; j < (len/2)-i; j++) {
System.out.print(" ");
}
for (int j = 0; j <= i; j++) {
System.out.print("* ");
}
System.out.println();
}else {
for (int j = 0; j < i-(len/2); j++) {
System.out.print(" ");
}
for (int j = 0; j < (2*(len/2))-i+1; j++) {
System.out.print("* ");
}
System.out.println();
}
}
System.out.println("OVER");
}
}
知识点:
1、循环的嵌套使用
2、读取键盘(Scanner)