std::vector<int> vec = {1, 2, 3};
vec.resize(2); // {1, 2}
vec.resize(4); // {1, 2, 0, 0,}
vec.resize(6, 9); // {1, 2, 0, 0, 9, 9}
dp.resize(n+1,vector<vector<int>>(n+1,vector<int>(n+1,-1)));
resize (size_type n, const value_type& val);
The resize() method (and passing argument to constructor is equivalent to that)
will insert or delete appropriate number of elements to the vector to make it
given size (it has optional second argument to specify their value).
The C++ function std::vector::resize() changes the size of vector. If n is smaller than current size then extra elements are destroyed.
If n is greater than current container size then new elements are inserted at the end of vector.
If val is specified then new elements are initialed with val.
Code Example |
---|
Cpp :: log in c++ |
Cpp :: ascii conversion cpp |
Cpp :: 3d projection onto 2d plane algorithm |
Cpp :: how do you wait in C++ |
Cpp :: bubblesort c++ |
Cpp :: print vector c++ |
Cpp :: chudnovsky algorithm c++ |
Cpp :: c++ get maximum value unsigned int |
Cpp :: cpp return array |
Cpp :: sleep in c++ |
Cpp :: float to int c++ |
Cpp :: c++ contains |
Cpp :: iterate over map c++ |
Cpp :: print two dimensional array c++ |
Cpp :: sort vector from largest to smallest |
Cpp :: c++ random generator |
Cpp :: c++ initialize static variable |
Cpp :: c++ Least prime factor of numbers till n |
Cpp :: c++ access second last element of vector |
Cpp :: getline() |
Cpp :: c++ client service ros |
Cpp :: c ++ split_string |
Cpp :: c++ recursion |
Cpp :: selection sort c++ |
Cpp :: find text in string c++ true false |
Cpp :: sweetalert2 email and password |
Cpp :: pop off end of string c++ |
Cpp :: ue4 int to enum c++ |
Cpp :: 344. reverse string c++ |
Cpp :: assignment operator with pointers c++ |