为了我们的任务。我们必须创建一个 Absolon 游戏。但首先我们必须让显示板正确。我使用 11 x 21 的 2D 阵列对显示器进行了编程。使用此代码。我得到了以下答案,并且打印正确。(IDE Neatbeans)
char [][] board = new char [11][21];
for(int column =6; column <= 14; column=column+2 ) {
int row = 0;
board[row][column] = '=';
}
for(int column =6; column <= 14; column=column+2 ) {
int row = 1;
board[row][column] = 'o';
}
for(int column =6; column <= 14; column=column+2 ) {
int row = 10;
board[row][column] = '=';
}
for(int column =6; column <= 14; column=column+2 ) {
int row = 9;
board[row][column] = 'x';
}
for(int column =5; column <= 15; column=column+2 ) {
int row = 2;
board[row][column] = 'o';
}
for(int column =5; column <= 15; column=column+2 ) {
int row = 8;
board[row][column] = 'x';
}
for(int column =5; column <= 15; column=column+2 ) {
int row = 8;
board[row][column] = 'x';
}
for(int column =8; column <= 12; column=column+2 ) {
int row = 3;
board[row][column] = 'o';
}
for(int column =8; column <= 12; column=column+2 ) {
int row = 7;
board[row][column] = 'x';
}
int j=1;
for(int column =4; column >= 0; column-- ) {
board[j][column] = '"';
j = j+1;
}
int l=1;
for(int column =16; column <= 20; column++ ) {
board[l][column] = '"';
l = l+1;
}
int m=6;
for(int column =1; column <= 4; column++ ) {
board[m][column] = '"';
m = m+1;
}
int n=6;
for(int column =19; column >= 16; column-- ) {
board[n][column] = '"';
n = n+1;
}
//Print Out Board
for(int row =0; row < board.length; row++) {
for(int column =0; column < board[row].length; column++) {
System.out.print(board[row][column] + "");
}
System.out.println();
}
}
}
这是我的示例输出的链接。 http://postimg.org/image/dx656twrf/
但是当我去校园工作时也使用neatbeans来解决同样的问题。它给了我一个全新的输出。
=====
“呜呜”
“呜呜呜”
“哦”
“”
“”
“”
“xxx”
“xxxxxx”
“xxxxx”
=====
怎么了。是IDE还是我的代码。请帮忙。