Answers for "vector includes c++"

C++
18

if vector contains value c++

#include <algorithm>

if(std::find(v.begin(), v.end(), x) != v.end()) {
    /* v contains x */
} else {
    /* v does not contain x */
}
Posted by: Guest on January-17-2020
1

taking a vector in c++ containing element

std::vector<int> v = { 4, 7, 5, 2, 6, 9 };
Posted by: Guest on November-10-2021

Browse Popular Code Answers by Language