What do you want to save?
Add Code snippet
New code examples
-
C++ 2021-10-28 18:36:05
removing element from vector while iterating c++
#include <iostream> #include <vector> #include <algorithm> int main() { std::vector<int> v = { 1, 2, 3, 4, 5, 6 }; auto it = v.begin(); while (it... Add solution -
C++ 2021-10-28 07:28:09
passing a 2d array cpp
#include <iostream> #include <vector> using namespace std; typedef vector< vector<int> > Matrix; void print(Matrix& m) { int M=m.size(); int N=m[0].size(); for(int i=0; i<M; i++) { for(int j=0; j<N; j++) ... Add solution -
C++ 2021-10-28 05:25:07
accumulate vector c++
#include <numeric> // Accumulate #include <vector> // Vector using namespace std; int main() { vector<int> nums{1,2,3,4,5}; int sum = 0; sum = accumulate(nums.begin(), nums.end(), sum); // nums.begin() -> first number in a l... Add solution -
C++ 2021-10-27 22:05:11
c++ sorting and keeping track of indexes
#include <iostream> #include <vector> #include <numeric> // std::iota #include <algorithm> // std::sort, std::stable_sort using namespace std; template <typename T> vector<size_t> sort_indexes(const vector<... Add solution -
C++ 2021-10-25 02:54:11
vector in c
#include <vector> std::vector<std::string> x; Add solution -
C++ 2021-10-23 05:28:04
c++ generate all subsets
#include <vector> #include <iostream> #include <cmath> using namespace std; int main() { // this is the length of the array of values // change variable "len" accordingly int len = 5; // this is the array of values int va... Add solution