Find the element in the given range of numbers. Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
Function Template :
InputIterator find (InputIterator first, InputIterator last, const T& val) first,last : Input iterators to the initial and final positions in a sequence. The range searched is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last. val : Value to be search in the range Return Value : An iterator to the first element in the range that compares equal to val. If no elements match, the function returns last.
Input : 10 20 30 40 Output : Element found at position : 3 // Search for 30 Input : 8 5 9 2 7 1 3 10 Output : Element not found. // Search for 4
Original vector : 10 20 30 40 Element 30 found at position : 3
This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Rearrange characters in a string such that no two adjacent are same using hashing
- Remove duplicate elements in an Array using STL in C++
- r-Nearest neighbors
- Increment (++) and Decrement (--) operator overloading in C++
- std::uniform_int_distribution max() method in C++ with examples
- boost::algorithm::clamp() in C++ library
- std::uniform_real_distribution max() method in C++ with Examples
- std::uniform_real_distribution reset() method in C++ with Examples
- std::uniform_real_distribution a() method in C++ with Examples
- std::uniform_int_distribution min() method in C++ with examples
- std::uniform_real_distribution b() method in C++ with Examples
- std::uniform_int_distribution b() method in C++ with examples
- std::uniform_int_distribution reset() method in C++ with examples
- std::uniform_real_ distribution class in C++ with Examples
- boost::algorithm::equal() in C++ library