(这是作业)我正在尝试打印一个带有行和列标题的Reversi板。我的问题是为什么不打印句号,而是打印"B“和"W”。有小费吗?
#include <iostream>
#include <cstdlib>
using namespace std;
const int BOARD_SIZE = 8, MOVE_SYMBOL = 3;
void PrintBoard(char board[8][8]);
int main(int argc, char* argv[]) {
const int BOARD_SIZE = 8;
char board[BOARD_SIZE][BOARD_SIZE] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, -1, 0, 0, 0 },
{ 0, 0, 0, -1, 1, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 }
};
PrintBoard(board);
}
// Prints current state of Reversi Board 15L
void PrintBoard(char board[BOARD_SIZE][BOARD_SIZE]) {
char output[MOVE_SYMBOL] = { 'W', ' . ', 'B' };
cout << "\n- 0 1 2 3 4 5 6 7";
for (int i = 0; i < BOARD_SIZE; i++) {
cout << "\n" << i;
for (int j = 0; j < BOARD_SIZE; j++) {
cout << output[board[i][j] + 1];
}
}输出:
- 0 1 2 3 4 5 6 7
0
1
2
3 BW
4 WB
5
6
7 Press any key to continue . . .发布于 2014-09-22 05:32:36
那是因为巫术能让你的经期舒缓。一个字符是一个单一的位置,所以'.'而不是' . '。
https://stackoverflow.com/questions/25967197
复制相似问题