版本比较
vscode 配置
正文
增加 228 行删除 96 行
21 行未改动22232425262728293031323334353637383940414243444546472627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140495051525354555657585960616263646566676869707172737475767778798014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721882838485868788899091929394959697989910010110210310410510610710810911011121922022111422222322422522612012122722812312412512612722923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326413326526626726826933 行未改动3033043053061753073083093103119 行未改动32132232332419332532632732832920 行未改动350351352353222354355356357358239 行未改动全部展开21 行未改动如需在 VS Code 内按快捷键编译,可创建 `.vscode/tasks.json` 文件。
```json{ "version": "2.0.0", "tasks": [ { "label": "编译 C++(评测版)", "type": "shell", "command": "g++", "args": [ "-std=c++14", "-O2", "-Wall", "-Wextra", "-g", "-Wl,--stack=1024000000", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${fileDirname}", "shell": { "executable": "C:\\Windows\\System32\\cmd.exe", "args": ["/d", "/c"] "version": "2.0.0", "tasks": [ { "label": "编译 C++(评测版)", "type": "shell", "command": "/usr/bin/g++", "args": [ "-std=c++14", "-O2", "-Wall", "-Wextra", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "silent", "panel": "shared", "clear": true } }, { "label": "编译 C++(调试版)", "type": "shell", "command": "/usr/bin/g++", "args": [ "-std=c++14", "-O0", "-g", "-Wall", "-Wextra", "-fsanitize=address,undefined", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": false }, "presentation": { "reveal": "silent", "panel": "shared", "clear": true } }, { "label": "运行 C++", "type": "shell", "command": "${fileDirname}/${fileBasenameNoExtension}", "options": { "cwd": "${fileDirname}" }, "dependsOn": [ "编译 C++(评测版)" ], "dependsOrder": "sequence", "presentation": { "reveal": "always", "panel": "shared", "clear": true, "focus": true }, "problemMatcher": [] }, { "label": "仅运行 C++", "type": "shell", "command": "${fileDirname}/${fileBasenameNoExtension}", "options": { "cwd": "${fileDirname}" }, "presentation": { "reveal": "always", "panel": "shared", "clear": true, "focus": true }, "problemMatcher": [] }, { "label": "运行 Python", "type": "shell", "command": "python3", "args": [ "${file}" ], "options": { "cwd": "${fileDirname}" }, "presentation": { "reveal": "always", "panel": "shared", "clear": true, "focus": true }, "problemMatcher": [] } }, "problemMatcher": ["$gcc"], "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "silent", "panel": "shared", "clear": true } }, { "label": "编译 C++(调试版)", "type": "shell", "command": "g++", "args": [ "-std=c++14", "-O0", "-g", "-Wall", "-Wextra", "-Wl,--stack=1024000000", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${fileDirname}", "shell": { "executable": "C:\\Windows\\System32\\cmd.exe", "args": ["/d", "/c"] ]}```windows 中:
```json{ "version": "2.0.0", "tasks": [ { "label": "编译 C++(评测版)", "type": "shell", "command": "g++", "args": [ "-std=c++14", "-O2", "-Wall", "-Wextra", "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-static-libgcc", "-static-libstdc++" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "silent", "panel": "shared", "clear": true } }, { "label": "运行 C++", "type": "shell", "command": "${fileDirname}\\${fileBasenameNoExtension}.exe", "options": { "cwd": "${fileDirname}" }, "dependsOn": [ "编译 C++(评测版)" ], "dependsOrder": "sequence", "presentation": { "reveal": "always", "panel": "shared", "clear": true, "focus": true }, "problemMatcher": [] }, { "label": "运行 Python", "type": "shell", "command": "python", "args": [ "${file}" ], "options": { "cwd": "${fileDirname}" }, "presentation": { "reveal": "always", "panel": "shared", "clear": true, "focus": true }, "problemMatcher": [] } }, "problemMatcher": ["$gcc"], "group": "build", "presentation": { "reveal": "silent", "panel": "shared", "clear": true } }, { "label": "运行 C++", "type": "shell", "command": "${fileDirname}/${fileBasenameNoExtension}.exe", "options": { "cwd": "${fileDirname}" }, "dependsOn": ["编译 C++(评测版)"], "dependsOrder": "sequence", "group": { "kind": "test", "isDefault": true }, "presentation": { "reveal": "always", "panel": "shared", "clear": true }, "problemMatcher": [] } ] ]}```配置后,按 `Ctrl+Shift+B` 即可编译当前文件。
## 一键编译运行
`Preferences: Open Keyboard Shortcuts (JSON)`
```txt// 将键绑定放在此文件中以覆盖默认值```json[ { "key": "ctrl+f5", "command": "workbench.action.tasks.runTask", "args": "运行 C++" } { "key": "ctrl+shift+b", "command": "workbench.action.tasks.build", "when": "resourceLangId == cpp" }, { "key": "ctrl+f5", "command": "workbench.action.tasks.runTask", "args": "运行 C++", "when": "resourceLangId == cpp" }, { "key": "ctrl+alt+r", "command": "workbench.action.tasks.runTask", "args": "仅运行 C++", "when": "resourceLangId == cpp" }, { "key": "ctrl+alt+p", "command": "workbench.action.tasks.runTask", "args": "运行 Python", "when": "resourceLangId == python" }, { "key": "ctrl+alt+z", "command": "glassit.increase" }, { "key": "ctrl+alt+c", "command": "glassit.decrease" }]```
# launch.json
```txt```json{ "version": "0.2.0", "configurations": [ {33 行未改动# 颜色配置
`Preferences: Open User Settings (JSON)`
```txt```json{ "vs64.showWelcome": false, "code-runner.runInTerminal": true, "editor.fontSize": 20,9 行未改动 "terminal.integrated.enableMultiLinePasteWarning": "never"}```
```txt```json{ "workbench.colorCustomizations": { "editorCursor.foreground": "#ffffff", "editorCursor.background": "#ffffff",20 行未改动 }}```
```txt```json{ "vs64.showWelcome": false, "code-runner.runInTerminal": true, "editor.fontSize": 20,239 行未改动全部展开