Search
 
SCRIPT & CODE EXAMPLE
 

CPP

vector.find()

#include <algorithm>
#include <vector>

if ( std::find(vec.begin(), vec.end(), item) != vec.end() )
   do_this();
else
   do_that();
Comment

vector find

#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v ;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    v.push_back(5);
    v.push_back(6);
    vector<int>::iterator it;
    it=find(v.begin(),v.end(),4);
    if(it!=v.end())
    cout<<it-v.begin()<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: find in string c++ 
Cpp :: c++ function for checking if a sting is a number 
Cpp :: remove last index of the string in c++ 
Cpp :: cpp multidimensional vector 
Cpp :: c++ prime sieve 
Cpp :: check if character is uppercase c++ 
Cpp :: sleep c++ 
Cpp :: header file for unordered_map in c++ 
Cpp :: How to find the suarray with maximum sum using divide and conquer 
Cpp :: remove element from array c++ 
Cpp :: convert string to lpwstr 
Cpp :: c++ isalphanum 
Cpp :: c++ get character from string 
Cpp :: swapping of two numbers 
Cpp :: convert decimal to binary in c++ 
Cpp :: c++ loop vector 
Cpp :: C++ Vector Iterator Syntax 
Cpp :: std::iomanip c++ 
Cpp :: how to remove a index from a string in cpp 
Cpp :: c++ double is nan 
Cpp :: c++ average 
Cpp :: how to set a variable to infinity in c++ 
Cpp :: c++ struct 
Cpp :: remove element from vector 
Cpp :: find element in vector 
Cpp :: sort vector c++ 
Cpp :: c++ string slicing 
Cpp :: c++ find object in vector by attribute 
Cpp :: count number of prime numbers in a given range in c 
Cpp :: rotate an array of n elements to the right by k steps 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =