/**
* 二维数组输出一个五子棋棋盘(如图)利用、┼、├、└、等
* @author yaolin
*/
public class Code {
public static void make(int width, int height) {
char[] t = { '┌', '┬', '┐', // 0 1 2
'├', '┼', '┤', // 3 4 5
'└', '┴', '┘' };// 6 7 8
if (width < 3 || height < 3) {
return; // 不能未成图
}
char[][] r = new char[width][height];
for (int i = 0; i < r.length; i++) {
r[i][0] = t[3]; // 最左侧
r[i][r[i].length - 1] = t[5]; // 最右侧
for (int j = 1; j < r[i].length - 1; j++) {
if (i == 0) {
r[i][j] = t[1]; // 最顶层
} else if (i == r.length - 1) {
r[i][j] = t[7]; // 最低层
} else {
r[i][j] = t[4];
}
}
}
r[0][0] = t[0]; // 左上角
r[0][width - 1] = t[2]; // 右上角
r[height - 1][0] = t[6]; // 左下角
r[height - 1][width - 1] = t[8]; // 右下角
for (int i = 0; i < r.length; i++) {
for (int j = 0; j < r[i].length; j++) {
System.err.print(r[i][j]);
}
System.err.println();
}
}
public static void main(String[] args) {
make(17, 17);
}
}