小编Sin*_*kri的帖子

数独求解算法C++

我正在努力制作一个Sudoku Solving程序几天,但我坚持使用这些方法.我在这里找到了这个算法,但我真的不明白它:

  1. 从第一个空单元格开始,并在其中放入1.
  2. 检查整个电路板,看看是否有任何冲突
  3. 如果电路板上有coflicts,请将当前单元格中的数字增加1(因此将1更改为2,将2更改为3等)
  4. 如果电路板干净移动,请再次从第一步开始.
  5. 如果给定单元格上的所有九个可能数字都会导致板上发生冲突,那么您将此单元格设置为空,返回上一个单元格,然后从步骤3重新开始(这是'回溯'进入的位置).

这是我的代码.我认为我的Help_Solve(...)函数出了问题.你能帮我解决一下这个问题吗?

    #include <iostream>
#include <iomanip>
#include <time.h>
#include <cstdlib>
#include <windows.h>
using namespace std;

class Sudoku
  {
    private:
    int board[9][9];
    int change[9][9];
    public:
    Sudoku();
    void Print_Board();  
    void Add_First_Cord();  
    void Solve();
    void Help_Solve(int i, int j);
    bool Check_Conflicts(int p, int i, int j);
  };

Sudoku Game;  

void setcolor(unsigned short color)                 //The function that you'll use to
{                                                   //set the colour
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hcon,color);
}

Sudoku::Sudoku()
  {
    for(int i = 1; …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm search artificial-intelligence graph

5
推荐指数
1
解决办法
4万
查看次数

二进制表达式树C ++

我有一点问题。我正在尝试将数学表达式添加到二叉树中,但我无法理解该算法。这里是:

If the current token is a '(':
 Add a new node as the left child of the current node, and 
 descend to the left child.
If the current token is in the list ['+','-','/','*']:
 Set the root value of the current node to the operator represented by the current token.
 Add a new node as the right child of the current node and descend to the right child.
If the current token is a number:
 Set the root value …
Run Code Online (Sandbox Code Playgroud)

c++ expression-trees

2
推荐指数
1
解决办法
8506
查看次数