mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
update cpp snippet
This commit is contained in:
parent
8b4133cd68
commit
710effaeb6
@ -24,14 +24,8 @@ snippet plist "print vector" w
|
|||||||
void printList(vector<int>& arr, const string& desc){
|
void printList(vector<int>& arr, const string& desc){
|
||||||
cout << desc << ": ";
|
cout << desc << ": ";
|
||||||
|
|
||||||
int N = arr.size();
|
for (auto it = arr.begin(); it != arr.end(); it++){
|
||||||
for (int i = 0; i < N; i++){
|
cout << *it << ((it != arr.end()-1) ? ' ' : '\n');
|
||||||
if (i != N -1){
|
|
||||||
cout << arr[i] << " ";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
cout << arr[i] << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -40,21 +34,15 @@ snippet pmat "print list of list" w
|
|||||||
void printMat(const vector<vector<int>>& mat, const string& desc){
|
void printMat(const vector<vector<int>>& mat, const string& desc){
|
||||||
cout << desc << ": " << endl;
|
cout << desc << ": " << endl;
|
||||||
|
|
||||||
int N = mat.size();
|
for (auto it1 = mat.begin(); it1 != mat.end(); it1++){
|
||||||
for (int i = 0; i < N; i++){
|
auto cur_vec = *it1;
|
||||||
int num = mat[i].size();
|
for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){
|
||||||
for (int j = 0; j < num; j++){
|
cout << *it2 << ((it2 != cur_vec.end()-1) ? ' ' : '\n');
|
||||||
if (j != num -1){
|
|
||||||
cout << mat[i][j] << " ";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
cout << mat[i][j] << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet cout "print a variable" w
|
snippet cout "print a variable" w
|
||||||
cout << "${1:var}: " << $1 << endl;
|
cout << "$1: " << $2 << endl;
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user