您当前的位置: 首页 >  算法

ZhangJiQun&MXP

暂无认证

  • 0浏览

    0关注

    1187博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

回溯算法之四皇后

ZhangJiQun&MXP 发布时间:2019-12-02 22:45:34 ,浏览量:0

 

代码:测试通过

测试地址:https://www.runoob.com/try/runcode.php?filename=helloworld&type=cpp

#include using namespace std;   class ChessBoard { public:     ChessBoard();    // 8 x 8 chessboard;自定义构造函数     ChessBoard(int); // n x n chessboard;带有参数的构造函数     void findSolutions(); private:     const bool available;     const int squares, norm;//squares代表棋盘格的边长,norm的意义在2、(4)中有提到     bool *column, *leftDiagonal, *rightDiagonal;//定义列,左斜线以及右斜线     int  *positionInRow, howMany;//定义行以及方法的数量     char m[10][10];//记录棋盘格     void putQueen(int);     void printBoard();     void initializeBoard();     void Delete();//释放new分配的动态内存 };   ChessBoard::ChessBoard() : available(true), squares(8), norm(squares - 1) {

关注
打赏
1665659684
查看更多评论
立即登录/注册

微信扫码登录

0.2165s