c++ - C++ 8乘8板

扫码查看

我正在尝试实施n皇后问题棋盘游戏,而我在棋盘上有问题
所以我在此显示板功能中在做什么错?它应该实现8 x 8的空白板,对不起,我只是一个初学者

#include <iostream>
#include <limits>

using namespace std;

const int rows = 8;
const int columns =8;

int board[rows][columns] = {0,0};

void displayboard();

int main(){

displayboard();

system("pause");

}
void displayboard ()
{

cout << "  1 2 3 4 5 6 7 8" << endl;
cout << "  ---------------";

for (int bRow = 0; bRow<rows; bRow++)
 {
 for (int bCol = 0; bCol<columns; bCol++)

  if (board[bRow][bCol] == 0)
         cout << " ";
  else
      cout << " ";
  }
 cout << endl;

  return;
 }

最佳答案

if (board[bRow][bCol] == 0)
      cout << " ";
else
      cout << " ";


??两者都做同样的事情!打印空白。此外,除了board[8][8]之外,您没有填充数组0

关于c++ - C++ 8乘8板,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8531318/

10-13 05:02
查看更多