public class 回型嵌套2 {
/**
* @param args
*/
public static String list[][];
public static void main(String[] args) {
// TODO Auto-generated method stub
int row = 0;
int col = 20;
list = new String[col][col];
while (col >= 11) {
fun(row, col);
row+=2;
col -=2;
}
for(int i =0;i<20;i++){
for(int j=0;j<20;j++){
System.out.print(list[i][j]);
}
System.out.println();
}
}
public static void fun(int row, int col) {
for (int i = row; i < col; i++) {
for (int j = row; j < col; j++) {
if (i == row || i == col - 1) {
list[i][j] = "*";
} else if (j == row || j == col - 1) {
list[i][j] = "*";
} else {
list[i][j] = " ";
}
}
}
}
}
蓝桥 回型嵌套
最新推荐文章于 2018-03-25 14:30:21 发布