Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
search_n algorithm
#include<iostream> #include<vector> #include<algorithm> int main() { // Sequence to search in std::vector<int> v1 = { 7, 6, 0, 4, 4, 9, 3, 4, 8 }; // Value to be searched for int v2 = 4; // Number of successive elements int v3 = 2; // Iterator for storing the returning pointer std::vector<int>::iterator i1; i1 = std::search_n(v1.begin(), v1.end(), v3, v2); // checking if iterator i1 contains end pointer of v1 or not if (i1 != v1.end()) { std::cout << "v2 is present consecutively 2 times at index " << (i1 - v1.begin()); } else { std::cout << "v2 is not present consecutively 2 times in " << "vector v1"; } return 0; }
run
|
edit
|
history
|
help
0
Operation on Set Container
Listas enlazadas - eliminar ocurrencias
remove_copy_if-30-Seconds-of-C++
Insertion Sort
grid
Make Bin Tree
codechef
Point on a ray--2133
Zadanie Kolokwium_2011_z4
მატრიცა#2