本教程只针对OI。
-
安装 VSCODE。
-
下载 MinGW:Winlibs、MinGW-w64 - for 32 and 64 bit Windows Files ,并将
.\bin添加到系统环境变量。对于 Linux
对于 NOI Linux 2.0 一般默认内置了 G++ 9.3.0。
可以输入
g++ --version查询,若安装则会返回:代码 g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.否则,请执行:
Bash sudo apt update # 更新,可注释 sudo apt install build-essential # 下载 gcc、g++ sudo apt install gdb # 下载 gdb -
安装插件
代码 C/C++ Code Runner vscode-pdf Material Icon Theme ... -
安装好后,新建一个文件:
Hello.cpp,点击右上角按钮运行,或Ctrl+Alt+N。C++ #include <bits/stdc++.h> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } -
更改一些设置 找到
Code Runner的设置,进入。勾选:
Code-runner: Run In Terminal
- Whether to run code in Integrated Terminal.
同时打开
Code-runner: Executor Map找到:"cpp":...替换为For Windows:
JSON "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \".\\$fileNameWithoutExt.exe\"",For Linux:
JSON "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" -O2 -std=c++14 -static && \"./$fileNameWithoutExt\"",```。