package test;
import java.util.Arrays;
/**
*
* @author Administrator
*/
public class Test {
final static char star='*';
final static char space=' ';
static void nextRow(char[][] a,int row,int col){
a[row][col]=star;
a[a.length-1-row][col]=star;
if(col<a[0].length&&col>0&&row<a.length/2){
nextRow(a, row+1,col+1);
nextRow(a, row+1,col-1);
}
}
public static void main(String[] args) {
int n=7;//星号数目
int peak=n-1;
char[][] s=new char[2*n-1][2*n-1];
nextRow(s, 0,peak);
String m;
for(char[] a:s){
m=Arrays.toString(a).replace(',',space).replace('[', space).replace(']', space);
System.out.println(m);
}
}
}
import java.util.Arrays;
/**
*
* @author Administrator
*/
public class Test {
final static char star='*';
final static char space=' ';
static void nextRow(char[][] a,int row,int col){
a[row][col]=star;
a[a.length-1-row][col]=star;
if(col<a[0].length&&col>0&&row<a.length/2){
nextRow(a, row+1,col+1);
nextRow(a, row+1,col-1);
}
}
public static void main(String[] args) {
int n=7;//星号数目
int peak=n-1;
char[][] s=new char[2*n-1][2*n-1];
nextRow(s, 0,peak);
String m;
for(char[] a:s){
m=Arrays.toString(a).replace(',',space).replace('[', space).replace(']', space);
System.out.println(m);
}
}
}