直接安装Node js和leetcode这个插件,登录之后选择code now之后选择目录,即可。
在代码模板中可以准备一个headers.h并且把它的import放到// @lc code=start
上面,把main放到// @lc code=end
下面
插件的设置可以在这个位置找到:
之后设置launch和tasks选项,我把我的拿过来:
launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| { "version": "0.2.0", "configurations": [ { "name": "(msvc) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/build/main.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "preLaunchTask": "msvc build" } ] }
|
tasks.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| { "version": "2.0.0", "tasks": [ { "label": "msvc build", "type": "shell", "command": "./build.bat", "args": ["${workspaceRoot}","${fileBasename}","${fileBasenameNoExtension}"], "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "always" }, "problemMatcher": "$msCompile" } ] }
|
另外,build.bat
如下
1 2 3 4 5 6 7 8
| @echo off call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" cd /d %1 mkdir build set compilerflags=/Od /Zi /EHsc /Wall /std:c++14 set linkerflags=/Fe:%1/build/main.exe cl.exe %compilerflags% %2 %linkerflags% del %3.obj
|