Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

split vector in half cpp

std::vector<int> vec = {89, 15, 51, 27, 98};
std::size_t const half_size = vec.size() / 2;
std::vector<int> half1(vec.begin(), vec.begin() + half_size);
std::vector<int> half2(vec.begin() + half_size, vec.end());
 
PREVIOUS NEXT
Tagged: #split #vector #cpp
ADD COMMENT
Topic
Name
4+1 =