I have the same question. And i have all ready done the recommend solution that i updated my GDB to v_11.2. And i also have added it to the system environment path and updated the launch and task file in vscode. Now i don’t know how to solve it. Looking forward to your help. Thanks!
Here is my output of debug:
=thread-group-added,id="i1"
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 5372.0x4f28]
[New Thread 5372.0x5498]
[New Thread 5372.0x4d88]
[Thread 5372.0x4d88 exited with code 3221225785]
[Thread 5372.0x5498 exited with code 3221225785]
[Thread 5372.0x2c64 exited with code 3221225785]
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". During startup program exited with code 0xc0000139.
The program 'pathexample.exe' has exited with code 0 (0x00000000).
My code is:
#include <unordered_set>
#include <vector>
using namespace std;
class Solution {
public:
bool isValid(int row, int col, char val, const vector<vector<char>>& board) {
// 行
for (int i = 0; i < 9; i++) {
if (board[row][i] == val)
return false;
}
// 列
for (int i = 0; i < 9; i++) {
if (board[i][col] == val)
return false;
}
// 九宫格不重复
// 获取当前处于的九宫格
int startRow = 3 * (row / 3);
int startCol = 3 * (col / 3);
// 这是利用双层循环,也可以利用unordered_set来检查
unordered_set<char> uset;
for (int i = startRow; i < startRow + 3; i++) {
for (int j = startCol; j < startCol + 3; j++) {
// 利用unordered_set
uset.insert(board[i][j]);
}
}
if (uset.find(val) != uset.end())
return false;
return true;
}
bool backtracking(vector<vector<char>>& board, int curRow, int curCol) {
// 其实可以不用,因为两层for在遍历完后会自动return
/* if (curRow == 8 && curCol == 9)
return true; */
for (int i = curRow; i < 9; i++) {
for (int j = curCol; j < 9; j++) {
if (board[i][j] == '.') {
for (char k = '1'; k <= '9'; k++) {
if (isValid(i, j, k, board)) {
board[i][j] = k;
if (backtracking(board, i, 0))
return true;
board[i][j] = '.';
}
}
return false;
}
}
}
return true;
}
void solveSudoku(vector<vector<char>>& board) {
backtracking(board, 0, 0);
}
};
int main() {
vector<std::vector<char>> board = {
{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
{'.', '.', '.', '.', '8', '.', '.', '7', '9'}};
Solution solution;
solution.solveSudoku(board);
return 0;
}
I have already searched solutions but it doesn’t work.
New contributor
xs_william is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5