0
what exactly does v.assign ?
int main() { vector<int> v; v.assign(5,3); cout<<v.size()<<endl; }
1 Resposta
+ 1
its assign a value 3 in the first 5 elements. think the vector like an array. at declaration its still empty []
on .assign(5,3) it'll assign a new size, then it'll everything with 3
[3,3,3,3,3]
more on that here https://en.cppreference.com/w/cpp/container/vector/assign