1. 安装拓展
Chinese是中文,需要重启才可以运行,C/C++拓展只是进行语法代码提示,不需要进行任何配置修改,默认即可。
2. 创建文件
C++是工作文件夹,.vscode是配置文件夹,里面建一个tasks.json文件,然后把下面内容复制进去
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++", // 如果没有配置环境变量可以直接改成g++.exe的文件路径
"args": [
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-g",
"-Wall",
"-fexec-charset=GBK",
"-std=c++11"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": "$gcc"
},
{
"label": "run",
"type": "shell",
"dependsOn": "build",
"command": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
}
]
}
3. 绑定快捷键
这样就配置好了,通过快捷键运行代码,会在终端进行输入输出交互。注意,这样配置是没有debug能力的,不过竞赛选手普遍都是肉眼debug,不需要这个功能。
4. 刷题模板
#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pc putchar
#define debug(x) cerr << #x" = " << x << '\n';
using namespace std;
inline int rd() { int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar(); return w ? -X : X;}
inline void wr(int x) { if (x < 0) pc('-'), x = -x; if (x > 9) wr(x / 10); pc(x % 10 + '0');}
void solve()
{
}
signed main()
{
int _ = 1;
// cin >> _;
while (_ --) solve();
return 0;
}