import java.util.*;
class Star1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入菱形中轴线所在的行数");
int row = sc.nextInt();
printLingXing(row);
}
public static void printLingXing(int m) {
for (int i = 1; i <= m; i++) {
for (int j = 1;j <= m-i ;j++ ) {
System.out.print(" ");
}
for (int k = m+1-i; k <=m-1+i; k++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <=m-1; i++) {
for (int j = 1;j <= i ;j++ ) {
System.out.print(" ");
}
for (int k = i ; k <=2*m-2-i; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
|