用VSCode刷codeforces的代码初始模板设置

codeforces和leetcode网站相比,需要自己写测试数据的输入代码,而且这些代码格式相对比较固定,因此利用vscode的代码片段来复用

个人一般使用java来刷题,修改java.json文件如下即可

{
	// Place your snippets for java here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"codeforces":{
		"prefix": "codeforces",
		"body": [
				"public static void main(String[] args) throws Exception {",
					"\tScanner sc = new Scanner(System.in);",
					"\tint n = Integer.parseInt(sc.nextLine());",
					"\tfor (int i = 0; i < n; ++i) {",
					"\t\tint cnt = sc.nextInt();",
					"\t\tint[] arr = new int[cnt];",
					"\t\tfor (int j = 0; j < cnt; ++j)  {",
					"\t\t\tarr[j] = sc.nextInt();",
					"\t\t}",
					"\t\t",
					"\t}",
					"\tsc.close();",
				"}",
		]
	}
}
posted @ 2025-03-19 09:17  kayaker  阅读(94)  评论(0)    收藏  举报