当前位置: 首页>>代码示例>>C++>>正文


C++ Puzzle::solve方法代码示例

本文整理汇总了C++中Puzzle::solve方法的典型用法代码示例。如果您正苦于以下问题:C++ Puzzle::solve方法的具体用法?C++ Puzzle::solve怎么用?C++ Puzzle::solve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Puzzle的用法示例。


在下文中一共展示了Puzzle::solve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printAndSolve

void printAndSolve( Puzzle sudoku ) {

  cout << "\nThe given puzzle looks like this: \n\n";

  sudoku.printBoard();

  if (!sudoku.solve()) {
    printf("Cannot solve puzzle\n");
    exit(0);
  }
    
  cout << "\n\nThe solved puzzle looks like this: \n\n";

  sudoku.printBoard();
  cout << "\n\n";
}
开发者ID:jgautsch,项目名称:Sudoku-Solver,代码行数:16,代码来源:main.cpp

示例2: main

int main(){
   Puzzle sudoku;
   cin >> sudoku;
   cout << "Unsolved Puzzle:" << endl;
   sudoku.display();
   cout << endl;
   //Solve returns true if solved, false if not.
   if (sudoku.solve(0, 0)) {
      cout << "Solved Puzzle:" << endl;
      sudoku.display();
      cout << endl;
   }
   else {
      cout << "Puzzle is unsolvable." << endl;
   }
   return 0;
}
开发者ID:kestemm,项目名称:work_examples,代码行数:17,代码来源:SudokuSolver.cpp

示例3: solve

void PartialSolver::solve()
{
    while(!puzzles.empty())
    {
        Puzzle& front = puzzles.front();
        ///Clear points to find points for next puzzle
        points.clear();
        findPoints(front.puzzle);
        list< pair<int,int> >::iterator it = points.begin();
        for(;it!=points.end(); it++)
        {
            int row = (*it).first;
            int col = (*it).second;
            Puzzle back = Puzzle(front);
            try
            {
                back.set(row, col, variable);
                back.solve();
                if(back.complete())
                {
                    if(back.correct())
                    {
                            solved.push_back(back);
                    }
                    else
                    {
                            incorrect.push_back(back);
                    }
                }
                else
                {
                    ///If the puzzle is still partially correct continue search
                    if(partiallyCorrect(back))
                        puzzles.push_back(back);
                }
            } catch (bool& value) {
                //incorrect.push_back(back);
            }
        }
        puzzles.pop_front();
    }
}
开发者ID:pcooksey,项目名称:skyscraper-ps,代码行数:42,代码来源:PartialSolver.cpp


注:本文中的Puzzle::solve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。