import java.util.Scanner;
class ouShu {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个0-20的偶数");
int i = sc.nextInt();
for (int x = 1;x <= i ;x++ ) {
for (int y = 1;y <= i ;y++ ) {
if(x <= i/2){ //<= 整个图形的一半,
if (y <= x || y > i-x) {
System.out.print("* ");
}else{
System.out.print("- ");
}
}else {
if (y <= i-x || y > x) {
System.out.print("* ");
}else
System.out.print(" ");
}
}
System.out.println();
}
}
}
|
|