c-homework/.vscode/c.code-snippets
2025-03-14 18:14:53 +08:00

45 lines
1.6 KiB
Plaintext

{
"Init file": {
"prefix": "init",
"body": ["#include <stdio.h>", "", "int main() {", " return 0;", "}"],
"description": "Init file"
},
"Define function swap two var with macro": {
"prefix": "fn_swap_macro",
"body": ["#define swap(a, b) { typeof(a) temp = a; a = b; b = temp; }"],
"description": "Define function swap two var with macro"
},
"Define var swapper": {
"prefix": "fn_define_swapper",
"body": [
"#define DEFINE_SWAPPER(type) \\",
" void swap_##type(type *a, type *b) { \\",
" type t = *a; \\",
" *a = *b; \\",
" *b = t; \\",
" }"
],
"description": "Define var swapper"
},
"Define function put bool": {
"prefix": "fn_putbool",
"body": ["#define putbool(x) (printf(\"%s\", (x) ? \"TRUE\" : \"FALSE\"))"],
"description": "Define function put bool"
},
"Define function max": {
"prefix": "fake_max",
"body": ["#define max(i, j) (((i) > (j)) ? (i) : (j))"],
"description": "Define function max"
},
"Define function min": {
"prefix": "fake_min",
"body": ["#define min(i, j) (((i) < (j)) ? (i) : (j))"],
"description": "Define function min"
},
"Fake loop": {
"prefix": "fake_loop",
"body": ["while (0) { // Fake loop", "}"],
"description": "Fake loop"
}
}