problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 静态 Private 成员函数 | 所有成员列表
leetcode::sudoku_solver::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static void solveSudoku (vector< vector< char > > &board)
 

静态 Private 成员函数

static bool dfs (const vector< vector< char > > &board, vector< vector< char > > &ans)
 
static bool valid (const vector< vector< char > > &board, int x, int y, char num)
 

详细描述

在文件 leetcode.h2986 行定义.

成员函数说明

◆ dfs()

bool leetcode::sudoku_solver::Solution::dfs ( const vector< vector< char > > &  board,
vector< vector< char > > &  ans 
)
staticprivate

在文件 leetcode.cpp8364 行定义.

8364 {
8365 for(int i = 0; i < 9; i++) {
8366 for(int j = 0; j < 9; j++) {
8367 if(board[i][j] == '.') {
8368 for(char c = '1'; c <= '9'; c++) {
8369 if(valid(board, i, j, c)) {
8370 bool haveValid = true;
8371 vector<vector<char>> next = board;
8372 next[i][j] = c;
8373 if(dfs(next, ans)) {
8374 return true;
8375 }
8376 }
8377 }
8378 return false;
8379 }
8380 }
8381 }
8382 ans = board;
8383 return true;
8384 }
static bool valid(const vector< vector< char > > &board, int x, int y, char num)
Definition: leetcode.cpp:8386
static bool dfs(const vector< vector< char > > &board, vector< vector< char > > &ans)
Definition: leetcode.cpp:8364

引用了 dfs() , 以及 valid().

被这些函数引用 dfs() , 以及 solveSudoku().

◆ solveSudoku()

void leetcode::sudoku_solver::Solution::solveSudoku ( vector< vector< char > > &  board)
static

在文件 leetcode.cpp8362 行定义.

8362{ dfs(board, board); }

引用了 dfs().

被这些函数引用 leetcode::sudoku_solver::TEST().

◆ valid()

bool leetcode::sudoku_solver::Solution::valid ( const vector< vector< char > > &  board,
int  x,
int  y,
char  num 
)
staticprivate

在文件 leetcode.cpp8386 行定义.

8386 {
8387 for(int i = 0; i < 9; i++) {
8388 if(board[i][y] == num) {
8389 return false;
8390 }
8391 }
8392 for(int j = 0; j < 9; j++) {
8393 if(board[x][j] == num) {
8394 return false;
8395 }
8396 }
8397 for(int i = 0; i < 3; i++) {
8398 for(int j = 0; j < 3; j++) {
8399 if(board[x / 3 * 3 + i][y / 3 * 3 + j] == num) {
8400 return false;
8401 }
8402 }
8403 }
8404 return true;
8405 }

被这些函数引用 dfs().


该类的文档由以下文件生成: