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
:: find in string c++ 
Cpp :: c++ function for checking if a sting is a number 
Cpp ::  
::  
:: c++ prime sieve 
Cpp :: armstrong number in cpp 
Cpp :: how to iterate throguh a string in c++ 
Cpp ::  
Cpp :: how to convert string into lowercase in cpp 
Cpp :: how to erase a certain value from a vector in C++ 
Cpp :: change int to string c++ 
Cpp ::  
:: hamming distance c++ 
:: check if a string is palindrome cpp 
:: sort index c++ 
Cpp :: console colors in C++ 
Cpp :: check if set contains element c++ 
Cpp :: how to reverse a vector 
Cpp :: sqrt in c++ 
Cpp ::  
Cpp :: sizeof’ on array function parameter ‘arr’ will return size of ‘int*’ [-Wsizeof-array-argument] 
:: cin getline 
Cpp :: vector to string cpp 
Cpp :: how to split string into words c++ 
Cpp :: power of a number 
Cpp :: sort vector from largest to smallest 
Cpp ::  
Cpp :: inline c++ 
:: doubly linked list code in c++ 
Cpp :: Subarray with given sum in c++ 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =