fork(2) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. std::vector<int> v{10, 25, 8, 49, 50, 61, 55, 45, 34, 10, 8};
  9. auto findIt = search_n(begin(v), end(v), 5, 40, [](int x, int y) { return y < x; });
  10. if (findIt == end(v)) cout << "Not found!";
  11. else cout << "Found at index " << distance(begin(v), findIt);
  12. cout << endl;
  13. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Found at index 3