diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index a47544117..d3af9b1eb 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -6,7 +6,7 @@ priority -50 #! header snippet #! "#!/usr/bin/env python" b -#!/usr/bin/env python +#!/usr/bin/env python3 $0 endsnippet diff --git a/snippets/c.snippets b/snippets/c.snippets index a3f4d5c99..c6e72842a 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -390,3 +390,16 @@ snippet asm : : ); + +snippet sd + scanf("%d", &${0:n}); +snippet s2d + scanf("%d%d", &${1:m}, &${0:n}); +snippet wsd + while (scanf("%d", &${1:n}) == 1) { + ${0} + } +snippet pdn + printf("%d\n", ${0:n}); +snippet pd + printf("%d", ${0:n}); diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index bb9528a6f..52fd77137 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,10 +1,30 @@ extends c +## Main +# main(void) +snippet cppmain + #include + ${1} + using namespace std; + + int main() { + ${0} + return 0; + } + +snippet cmain + #include + ${1} + using namespace std; + + int main() { + ${0} + return 0; + } ## Main # main() snippet mainn - int main() - { + int main() { ${0} return 0; } @@ -13,6 +33,8 @@ snippet mainn # #include <...> snippet incc #include <${1:iostream}> +snippet incv + #include <${1:vector}> snippet binc #include ## @@ -23,6 +45,8 @@ snippet array # std::vector snippet vector std::vector<${1:T}> ${2}; +snippet vvi + vector> ${1}(${2:n}, vector(${3:m}, ${4:0})); # std::deque snippet deque std::deque<${1:T}> ${2}; @@ -190,7 +214,6 @@ snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4} } - # foreach snippet fore for (${1:auto} ${2:i} : ${3:container}) { @@ -277,3 +300,55 @@ snippet gtepar "GTest:add parameterized test" # GTest:instantiate parameterized test snippet gteparins "GTest:instantiate parameterized test" INSTANTIATE_TEST_SUITE_P(${1:InstantiationName}, ${2:SuiteName}, ${0}); + +snippet sedge "struct edge" + struct edge { + int to, next; + edge(int to, int next) : to(to), next(next) {} + }; + +snippet sedgew "struct edge" + struct edge { + int to, next, w; + edge(int to, int next, int w) : to(to), next(next), w(w) {} + }; + +snippet vi "vector" + vector + +snippet cgraph "class Graph" + struct Edge { + int to, next; + Edge(int to, int next) : to(to), next(next) {} + }; + + class Graph { + vector head; + vector edges; + public: + Graph(int n) : head(n + 1, -1) {} + void add_edge(int u, int v) { + edges.emplace_back(v, head[u]); + head[u] = edges.size() - 1; + } + ${0} + }; + +snippet cgraphw "class Graph" + struct Edge { + int to, next, w; + Edge(int to, int next, int w) : to(to), next(next), w(w) {} + }; + + class Graph { + vector head; + vector edges; + public: + Graph(int n) : head(n + 1, -1) {} + void add_edge(int u, int v, int w) { + edges.emplace_back(v, head[u], w); + head[u] = edges.size() - 1; + } + ${0} + }; +