@@ -33,23 +33,27 @@ var (
3333 languageConfigs = map [string ]LanguageConfig {
3434 "go" : {
3535 LeetcodeLang : "Go" ,
36- TplFiles : []TplFile {{"code" , "solve_ %s.go" , codeStrGo }, {"test" , "solve_ %s_test.go" , testCodeStrGo }},
36+ TplFiles : []TplFile {{"code" , "%s.%s. go" , codeStrGo }, {"test" , "%s. %s_test.go" , testCodeStrGo }},
3737 },
3838 "ts" : {
3939 LeetcodeLang : "TypeScript" ,
40- TplFiles : []TplFile {{"code" , "solve_ %s.ts" , codeStrTs }, {"test" , "solve_ %s.test.ts" , testCodeStrTs }},
40+ TplFiles : []TplFile {{"code" , "%s.%s. ts" , codeStrTs }, {"test" , "%s. %s.test.ts" , testCodeStrTs }},
4141 },
4242 "js" : {
4343 LeetcodeLang : "JavaScript" ,
44- TplFiles : []TplFile {{"code" , "solve_ %s.js" , codeStrJs }, {"test" , "solve_ %s.test.js" , testCodeStrJs }},
44+ TplFiles : []TplFile {{"code" , "%s.%s. js" , codeStrJs }, {"test" , "%s. %s.test.js" , testCodeStrJs }},
4545 },
4646 "py3" : {
4747 LeetcodeLang : "Python3" ,
48- TplFiles : []TplFile {{"code" , "solve_ %s.py" , codeStrPy3 }, {"test" , "test_%s .py" , testCodeStrPy3 }, {"__init__" , "__init__.py" , "" }},
48+ TplFiles : []TplFile {{"code" , "%s.%s. py" , codeStrPy3 }, {"test" , "%s.%s_test .py" , testCodeStrPy3 }, {"__init__" , "__init__.py" , "" }},
4949 },
5050 "java" : {
5151 LeetcodeLang : "Java" ,
52- TplFiles : []TplFile {{"code" , "solve_%s.java" , codeStrJava }, {"test" , "test_%s.java" , testCodeStrJava }},
52+ TplFiles : []TplFile {{"code" , "%s.%s.java" , codeStrJava }, {"test" , "test_%s_%s.java" , testCodeStrJava }},
53+ },
54+ "cpp" : {
55+ LeetcodeLang : "C++" ,
56+ TplFiles : []TplFile {{"code" , "%s.%s.cpp" , codeStrCpp }},
5357 },
5458 }
5559)
@@ -103,7 +107,7 @@ func Run(lc *leetcode.Leetcode, n string, lang string) {
103107 log .Fatal (err , meta )
104108 }
105109 number := normalizeNumber (meta .Index )
106- folderName := prefix + number
110+ folderName := number + "." + meta . Slug
107111 fp := filepath .Join (folder , folderName )
108112 _ = os .MkdirAll (fp , 0755 )
109113 metaf := & MetaWithFolder {
@@ -123,8 +127,8 @@ func Run(lc *leetcode.Leetcode, n string, lang string) {
123127
124128 for _ , tpl := range config .TplFiles {
125129 fileName := tpl .FileName
126- if strings .Count (tpl .FileName , "%s" ) > 0 {
127- fileName = fmt .Sprintf (tpl .FileName , number )
130+ if strings .Count (tpl .FileName , "%s" ) > 1 {
131+ fileName = fmt .Sprintf (tpl .FileName , number , meta . Slug )
128132 }
129133 fp := filepath .Join (fp , fileName )
130134 if ! fileExists (fp ) {
@@ -245,3 +249,26 @@ public class test_{{ printf "%04s" .Index }} {
245249}
246250`
247251)
252+
253+ var (
254+ codeStrCpp = `#include <algorithm>
255+ #include <unordered_map>
256+ #include <string>
257+ #include <vector>
258+ #include <iostream>
259+ #include <math.h>
260+ using namespace std;
261+
262+ /**
263+ * @index {{ .Index }}
264+ * @title {{ .Title }}
265+ * @difficulty {{ .Difficulty }}
266+ * @tags {{ .TagStr }}
267+ * @draft false
268+ * @link {{ .Link }}
269+ * @frontendId {{ .FrontendId }}
270+ * @solved {{ .Solved }}
271+ */
272+ {{ .Code }}
273+ `
274+ )
0 commit comments