class ClassTest {
public static void main(String[] args){
print(4);
}
public static void print(int a ){
for (int i=1;i<=2*a-1 ;i++ ) {
if (i<=a) {
for (int j =1;j<=2*a-1 ;j++ ) {
if (j==a+1-i||j==a+i-1) {
System.out.print("*");
}else {
System.out.print(" ");
}
}
System.out.println();
}else {
for (int j =1;j<=2*a-1 ;j++ ) {
if (j==i-a+1||j==3*a-i-1) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
}
|
|