aboutsummaryrefslogtreecommitdiff
path: root/my_snippets/cpp.snippets
blob: 5046814ce7f15d1fdbbd9153a26a72a57dc767a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
snippet bare "barebone code template"
#include <iostream>
#include <vector>
#include <string>

using std::cout;
using std::endl;
using std::vector;
using std::string;


int main()
{

}
endsnippet

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