vscode 用户代码片段
如何新建代码片段
左下角(齿轮)设置 --> 用户代码片段 --> 输入名字新建代码片段
我的在右下角
输入名字新建即可
下面附上我的代码片段
代码片段格式
{
"atc-model": {
"prefix": "cpp", //代码片段的名字,即输入 cpp + 回车 即可生成这个代码
"body": [
"#include <bits/stdc++.h>",
"#define fi first ",
"#define se second ",
"#define pb push_back",
"#define mk make_pair",
"#define leng(a) (int)a.size()",
"#define lowbit(x) (x&-x)",
"#define lb lower_bound",
"#define ub upper_bound",
"#define fix(a) fixed << setprecision(a) ",
"#define debug(x) cout<<#x\" ----> \"<<x<<endl",
"#define rep(i, b, s) for(int i = (b); i <= (s); ++i)",
"#define pre(i, b, s) for(int i = (b); i >= (s); --i)",
"#define TEST int T; read(T); while(T --) ",
"",
"//#define int long long ",
"#define endl '\\n' ",
"#define ios ios::sync_with_stdio(false); cin.tie(0), cout.tie(0)",
"#define all(v) (v).begin(),(v).end()",
"",
"using namespace std;",
" ",
"typedef unsigned long long ULL;",
"typedef pair<int, int> PII ;",
"typedef pair<int, PII> PIII ;// {value, {value, value}}",
"typedef pair<double, double> PDD ;",
"typedef long long LL;",
"const int INF = INT_MAX;",
"const LL INFF = INT64_MAX;",
"const int MOD = 998244353;",
"const double eps = 1e-10;",
"const double pi = acos(-1.0);",
"mt19937 mrand(random_device{}()); ",
" ",
"inline int sgn(double x) {return (x > eps) - (x < -eps);} ",
"//x >= y 写成 sgn(x - y) >= 0",
"LL gcd(LL a, LL b) {return b ? gcd(b, a%b) : a;}",
"inline LL ksm(LL a, LL b) { LL ns = 1; a %= MOD; if(a == 0) return 0; while(b) { if(b & 1) ns = ns * a % MOD; b >>= 1; a = a * a % MOD;} return ns; }",
"inline LL ksm(LL a, LL b, int Mod) { LL ns = 1; a %= Mod; if (a == 0) return 0; while(b) { if(b & 1) ns = ns * a % Mod; b >>= 1; a = a * a % Mod; } return ns; }",
"inline LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}",
"inline void out(bool flag);",
"int rnd(int x) { return mrand() % x;}",
"inline bool valid(char c) { return 33<=c&&c<=126; }",
"template <typename T> void chkmax(T &x, T y) { x = max(x, y); }",
"template <typename T> void chkmin(T &x, T y) { x = min(x, y); }",
"template <typename T> inline T mod(T &x) {return x % MOD;}",
"template < typename T >",
"inline void read(T &x)",
"{",
" x = 0; bool f = 0; char ch = getchar();",
" while(!isdigit(ch)){f ^= !(ch ^ 45);ch=getchar();}",
" while(isdigit(ch)) x= (x<<1)+(x<<3)+(ch&15),ch=getchar();",
" x = f ? -x : x;",
"}",
"template<typename T,typename ...Args>void read(T &x, Args &...args)",
"{ read(x),read(args...); }",
"template <typename T> void read(vector<T> &A) { for(T &x: A) read(x);};",
"inline void reads(char *s) {",
" int l=0;char c;",
" while(!valid(s[0]=getchar()));",
" while(valid(s[++l]=getchar()));",
"}",
"",
"",
"//isalnum(char) 判断字符是否是 字母 or 数字",
"//isalpha(char) 判断字符是否是 字母",
"//isdigit(char) 判断字符是否是数字",
"//__builtin_clzll(x) 返回x的前导零的个数",
"// __builtin_popcount(x) 返回x中1的个数",
"// __lg(x) 返回x的二进制下的位数(去除前导零实现,特判0)",
"//map<key,value>; key 可以是PII",
"",
"//再用unordered_map 是sb",
"",
"//数组清空到 n + 100 !!!!1",
"inline void solve() {",
" $0",
"}",
" ",
"signed main() ",
"{",
"",
" solve();",
" ",
" return 0;",
"}",
" ",
" ",
"inline void out(bool flag) {",
" if(flag) puts(\"Yes\");",
" else puts(\"No\");",
"}"
//scanf(\"%d\",&T);
],
"description": "init cf model" //没啥用
},
}
生成代码片段
输入完代码后记得
Ctrl + Z
结束运行,片段会生成到同目录下的1.txt
中,直接复制即可
#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("1.txt", "w", stdout);
string s;
while(getline(cin, s)) {
cout << "\"" << s << "\",\n";
}
return 0;
}