提问人:Nguyễn Việt Hưng 提问时间:10/7/2023 最后编辑:marc_sNguyễn Việt Hưng 更新时间:11/4/2023 访问量:36
调试器不命中任何断点
Debugger does not hit any breakpoints
问:
我尝试在 vs code 上使用调试模式,但是当我设置断点和调试时,它没有命中任何点,只是执行程序并记下输出。
我的配置launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [
//"${fileDirname}\\${fileBasenameNoExtension}.inp"//the input file's directory
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
task.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
settings.json文件
{
"files.associations": {
"iostream": "cpp",
"numeric": "cpp",
"ostream": "cpp",
"iomanip": "cpp",
"*.tcc": "cpp",
"valarray": "cpp",
"sstream": "cpp",
"regex": "cpp",
"map": "cpp",
"limits": "cpp"
}
}
我的代码示例
#include<iostream>
#include<algorithm>
#define FOR(n) for(int i = 1; i <= n; ++i)
#define lim (long long int)(10E9 + 7)
void IO(std::string filename){
freopen((std::string{filename} + ".inp").c_str(), "r", stdin);
freopen((std::string{filename} + ".out").c_str(), "w", stdout);
return ;
}
struct properties{
int x;
int y;
} pos[1000001];
unsigned long long int res = 0, remain = 1, dup = 1;
long long int inputNumber;
int main(){
//IO("CHICK");
std::cin>>inputNumber;
FOR(inputNumber){
std::cin>>pos[i].x>>pos[i].y;
}
std::sort(pos + 1, pos + 1 + inputNumber, [](struct properties &a, struct properties &b){
return a.y < b.y;
});
pos[inputNumber + 1].x = 1000000000;
pos[inputNumber + 1].y = 1000000000;
FOR(inputNumber){
if(pos[i].y == pos[i + 1].y){
++dup;
}
else{
res += dup * (dup - 1) / 2;
dup = 1;
}
}
dup = 1;
std::sort(pos + 1, pos + 1 + inputNumber, [](struct properties &a, struct properties &b){
if(a.x == b.x){
return a.y < b.y;
}
return a.x < b.x;
});
FOR(inputNumber){
if(pos[i].x == pos[i + 1].x){
++dup;
if(pos[i].y == pos[i + 1].y){
++remain;
}
else{
res -= remain * (remain - 1) / 2;
remain = 1;
}
}
else{
res += dup * (dup - 1) / 2;
res -= remain * (remain - 1) / 2;
dup = 1;
remain = 1;
}
}
std::cout<<res;
}
我已经在互联网上搜索了这个问题,但我找不到任何解决方案,还尝试使用外部控制台 stopAtEntry,从两个文件中获取输入并手动输入它们。没有任何变化
答: 暂无答案
评论
#define FOR(n) for(int i = 1; i <= n; ++i) #define lim (long long int)(10E9 + 7)
“ - 你应该停止听那些教你这是个好主意的人。