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


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

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


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

示例1: main

int main()
{
	Sudoku ss;
	int num;
	int i,j,k;
	int count = 0;
	while(cin >> num)
	{
		count++;
		if(count!=1 && ans_count != 0)
			cout << endl << endl;
		else if(count !=1)
			cout << endl;
		for(i=0; i<9; i++)
		{
			for(j=0; j<9; j++)
			{
				su[i][j] = 0;
				su3[i][j][0] = 0;
				ans[i][j] = 0;
				su2[i][j] = 0;
				for(k=1; k<10; k++)
				{
					su3[i][j][k] = 1;
				}
			}
		}
		have_zero = false;
		ans_count = 0;
		ss.readIn(num);
		ss.solve(num);
	}
}
开发者ID:bladeath860620,项目名称:ACM,代码行数:33,代码来源:UVA-989.cpp

示例2: main

int main(){
	Sudoku ss;
	ss.readIn();
	ss.solve();

	return 0;
}
开发者ID:stbn199650,项目名称:pd2-sudoku,代码行数:7,代码来源:solve.cpp

示例3: solve

bool Sudoku::solve()
{
  if(fin()){
    return true; 
  }
  while(1){
    Move m = findMove();
    if(m.val == 0){
      //no more moves
      return false;
    }
    Sudoku scopy = *this;
    bool result = scopy.applyMove(m);
    if(!result){
      cand[m.ii][m.jj][m.val] = false;
      continue;
    }
    result = scopy.solve();
    if(result){
      *this = scopy;
      return true;
    }else{
      cand[m.ii][m.jj][m.val] = false;
    }
  }
  return false;
}
开发者ID:desaic,项目名称:matchtex,代码行数:27,代码来源:Sudoku.cpp

示例4: sudokuTest

void sudokuTest() {
  vector< vector<int> > _grid = 
  {{3, 0, 6, 5, 0, 8, 4, 0, 0},
    {5, 2, 0, 0, 0, 0, 0, 0, 0},
    {0, 8, 7, 0, 0, 0, 0, 3, 1},
    {0, 0, 3, 0, 1, 0, 0, 8, 0},
    {9, 0, 0, 8, 6, 3, 0, 0, 5},
    {0, 5, 0, 0, 9, 0, 6, 0, 0},
    {1, 3, 0, 0, 0, 0, 2, 5, 0},
    {0, 0, 0, 0, 0, 0, 0, 7, 4},
    {0, 0, 5, 2, 0, 6, 3, 0, 0}};

  Sudoku* puzzle = new Sudoku( _grid );
  if(!puzzle->IsLegalBoard()) {
    drunkout("Illegal board.", cERROR);
  }
  puzzle->print();

  if(puzzle->solve())
    puzzle->print();
  else
    drunkout("No solution.", cINFO);

  delete puzzle;

}
开发者ID:madisodr,项目名称:Drunken-Algorithms,代码行数:26,代码来源:main.cpp

示例5: main

/**
 * Main method that gets initialized upon start of the program and creates an instance of the class Sudoku. A function
 * belonging to the Sudoku class is called that will generate a completely solved sudoku board and then the pointer to
 * the class is deleted to free up the allocated memory.
 */
int main() {
    Sudoku * mySudoku = new Sudoku();
    mySudoku->solve();
    delete mySudoku;

    return 0;
}
开发者ID:tonyzheng6,项目名称:Sudoku_Board_Solver,代码行数:12,代码来源:main.cpp

示例6: main

int main()
{
	Sudoku sudoku;
	sudoku.readIn();
	sudoku.solve();
	
	return 0;
}
开发者ID:F74046399,项目名称:pd2-sudoku,代码行数:8,代码来源:solve.cpp

示例7: main

int main()
{
	Sudoku sdk;
	sdk.readIn();
	sdk.solve();
	system("PAUSE");
	return 0;
}
开发者ID:yusun1997,项目名称:pd2-sudoku,代码行数:8,代码来源:solve.cpp

示例8: main

int main(int argc, const char * argv[]) {
    
    Sudoku ss;
    ss.readIn();
    ss.solve();
    
    return 0;
}
开发者ID:EvanChenPrograming,项目名称:pd2--sudoku,代码行数:8,代码来源:solve.cpp

示例9: main

int main(){
	Sudoku ss;
	ss.readIn();
//	ss.rotate(83);
//	ss.flip(1);
//	ss.changeNum(3,6);
//	ss.changeRow(0,2);
//	ss.changeCol(0,2);
	ss.solve();
	return 0;
}
开发者ID:stbn199650,项目名称:pd2-sudoku,代码行数:11,代码来源:main.cpp

示例10: main

int main() {
    string board;
    while (getline(cin, board)) {
        Sudoku game = board;
        game.print();
        game.solve();
        game.print();
        cout << game.exportString() << endl;
    }
    return 0;
}
开发者ID:SquishyStrawberry,项目名称:cpp-sudoku-solver,代码行数:11,代码来源:main.cpp

示例11: main

int main(int argc, char** argv) {
	if (argc != 3) {
		puts("Format: main.out input_filename output_filename");
		exit(1);
	}
	char* infilename = argv[1];
	char* outfilename = argv[2];
	Sudoku sudoku;
	sudoku.load(infilename, SUDOKUSIZE, SUDOKUUNITSIZE);
	sudoku.solve();
	sudoku.print(outfilename);
	return 0;
}
开发者ID:mengcz13,项目名称:ai2016,代码行数:13,代码来源:main.cpp

示例12: main

int main()
{

	system("color 4B");
	// sound //
	UINT wDeviceID;  //a device ID so we can keep track of it once we open it.
	DWORD dwReturn;	//a return value..
	MCI_OPEN_PARMS mciOpenParms; //Structure for the MCI_OPEN command
	MCI_PLAY_PARMS mciPlayParms; //Structure for the MCI_PLAY command
	mciOpenParms.lpstrDeviceType = TEXT("waveaudio");
	mciOpenParms.lpstrElementName = TEXT("mortal.wav");
	if (dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciOpenParms))
	{

		cout << "sound file unavailable.\n";
	}
	// The device opened successfully; get the device ID.
	wDeviceID = mciOpenParms.wDeviceID;

	if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, 0, NULL))
	{
		mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);

		return (dwReturn);
	}
	// Establish Local variables
	string master_loop = "y", inputFile;
	int in_value;

	// Create pointer to Sudoku Class
	Sudoku *solution;
	
	do // Start of master_loop
	{
		cout << "\n*===*===*===*===*===*===*===*===*===*===*===*===*===*===*" << "\n|\t\t\t\t\t\t\t|" << endl;
		cout << "|\t\t\t FIGHTING            \t\t|" << "\n|\t\t\t\t\t\t\t|" << endl;
		cout << "|     /////  //  //  ////   //////  //   //  //  //     |" << endl;
		cout << "|  *  //     //  //  //  /  //  //  // //    //  //  *  |" << endl;
		cout << "| **  /////  //  //  //  /  //  //  ///      //  //  ** |" << endl;
		cout << "|  *     //  //  //  //  /  //  //  // //    //  //  *  |" << endl;
		cout << "|     /////  //////  ////   //////  //  //   //////     |" << endl;
		cout << "|\t\t\t\t\t\t TM  \t|" << "\n|\t\t\t\t\t\t\t\|" << endl;
		cout << "|      * Anthony * Chad * Jason * Michael * Scott *     |" << endl;
		cout << "*===*===*===*===*===*===*===*===*===*===*===*===*===*===*" << endl;

		// Ask the user to input the path to or a file name
		cout << "\n\nYou must input a Sudoku Fighting file name: ";

		// Read in user input assign the variable
		cin >> inputFile;

		// Attempt to open the file
		fstream inFile(inputFile);

		// If file can not open
		if (!inFile)
		{
			cout << "\nHA!!!!, your puny file "<< inputFile << " is not detected. \nYou have to enter it correctly to fight. \nTry again.\n" << endl;
			system("PAUSE");
			system("CLS");
		}

		// If the file is found continue on with program
		else
		{
			// Create new Sudoku Solution
			solution = new Sudoku;

			// Read data into Sudoku
			while (inFile >> in_value)
			{
				solution->fill_board(in_value);
			}

			// Print inputed Sudoku puzzle
			solution->print_Board();

			// Pause to allow user to view inputed Sudoku puzzle
			cout << "\n\nAre you ready to Fight?\n" << endl;
			system("PAUSE");

			// Call Sudoku Solution
			solution->solve(0, 0);

			// Print solved Sudoku puzzle
			solution->print_Board();

			// Conclusion
			mciOpenParms.lpstrElementName = TEXT("flawless.wav");
			cout << "\n\n\Hooozah! That's why they call me the Sudoku Fighter.\n" << endl;

			do
			{
				// Ask user if they would like to try the program again
				cout << "Would you like to fight again? (y) or (n): ";

				// Read input
				cin >> master_loop;

				// If not valid reponse explain, and promt user to try again
//.........这里部分代码省略.........
开发者ID:rukeyscott,项目名称:Sudoku_fighter,代码行数:101,代码来源:Source.cpp


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