diff options
| author | jdhao <jdhao@hotmail.com> | 2021-06-20 19:11:33 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-06-20 19:14:47 +0800 |
| commit | 8b4133cd6859b21fffbed77d4be015a9ed7985ed (patch) | |
| tree | 39bbc2a659a485099656defeda447234c4761fa1 | |
| parent | 157ea91abb6390274e0bbb697d76c923768aa85f (diff) | |
Add cpp snippet
| -rw-r--r-- | my_snippets/cpp.snippets | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/my_snippets/cpp.snippets b/my_snippets/cpp.snippets index f846244..5046814 100644 --- a/my_snippets/cpp.snippets +++ b/my_snippets/cpp.snippets @@ -19,3 +19,42 @@ snippet icd "#include directive" b #include <$1> $0 endsnippet + +snippet plist "print vector" w +void printList(vector<int>& arr, const string& desc){ + cout << desc << ": "; + + int N = arr.size(); + for (int i = 0; i < N; i++){ + if (i != N -1){ + cout << arr[i] << " "; + } + else{ + cout << arr[i] << endl; + } + } +} +endsnippet + +snippet pmat "print list of list" w +void printMat(const vector<vector<int>>& mat, const string& desc){ + cout << desc << ": " << endl; + + int N = mat.size(); + for (int i = 0; i < N; i++){ + int num = mat[i].size(); + for (int j = 0; j < num; j++){ + if (j != num -1){ + cout << mat[i][j] << " "; + } + else{ + cout << mat[i][j] << endl; + } + } + } +} +endsnippet + +snippet cout "print a variable" w +cout << "${1:var}: " << $1 << endl; +endsnippet |
